Adam Shaw 8 лет назад
Родитель
Сommit
5934687564
2 измененных файлов с 15 добавлено и 26 удалено
  1. 11 17
      src/common/ChronoComponent.js
  2. 4 9
      src/models/ComponentFootprint.js

+ 11 - 17
src/common/ChronoComponent.js

@@ -558,25 +558,19 @@ var ChronoComponent = Model.extend({
 	computeDayRange: function(unzonedRange) {
 		var calendar = this.calendar || this.view.calendar; // TODO: move away from using!
 		var startDay = calendar.msToUtcMoment(unzonedRange.startMs, true); // the beginning of the day the range starts
-		var end = calendar.msToUtcMoment(unzonedRange.endMs, true);
-		var endDay = null;
-		var endTimeMS;
-
-		if (end) {
-			endDay = end.clone().stripTime(); // the beginning of the day the range exclusively ends
-			endTimeMS = +end.time(); // # of milliseconds into `endDay`
-
-			// If the end time is actually inclusively part of the next day and is equal to or
-			// beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
-			// Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
-			if (endTimeMS && endTimeMS >= this.nextDayThreshold) {
-				endDay.add(1, 'days');
-			}
+		var end = calendar.msToUtcMoment(unzonedRange.endMs);
+		var endTimeMS = +end.time(); // # of milliseconds into `endDay`
+		var endDay = end.clone().stripTime(); // the beginning of the day the range exclusively ends
+
+		// If the end time is actually inclusively part of the next day and is equal to or
+		// beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
+		// Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
+		if (endTimeMS && endTimeMS >= this.nextDayThreshold) {
+			endDay.add(1, 'days');
 		}
 
-		// If no end was specified, or if it is within `startDay` but not past nextDayThreshold,
-		// assign the default duration of one day.
-		if (!end || endDay <= startDay) {
+		// If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
+		if (endDay <= startDay) {
 			endDay = startDay.clone().add(1, 'days');
 		}
 

+ 4 - 9
src/models/ComponentFootprint.js

@@ -18,15 +18,10 @@ var ComponentFootprint = FC.ComponentFootprint = Class.extend({
 	Only works for non-open-ended ranges.
 	*/
 	toLegacy: function(calendar) {
-		var start = calendar.moment(this.unzonedRange.startMs);
-		var end = calendar.moment(this.unzonedRange.endMs);
-
-		if (this.isAllDay) {
-			start.stripTime();
-			end.stripTime();
-		}
-
-		return { start: start, end: end };
+		return {
+			start: calendar.msToMoment(this.unzonedRange.startMs, this.isAllDay),
+			end: calendar.msToMoment(this.unzonedRange.endMs, this.isAllDay)
+		};
 	}
 
 });