Просмотр исходного кода

moment-2.8 compatibility, source (2.1), .add() calls

Adam Shaw 11 лет назад
Родитель
Сommit
6c04fca1f3

+ 2 - 2
src/agenda/AgendaDayView.js

@@ -16,7 +16,7 @@ $.extend(AgendaDayView.prototype, {
 
 
 	incrementDate: function(date, delta) {
-		var out = date.clone().stripTime().add('days', delta);
+		var out = date.clone().stripTime().add(delta, 'days');
 		out = this.skipHiddenDays(out, delta < 0 ? -1 : 1);
 		return out;
 	},
@@ -25,7 +25,7 @@ $.extend(AgendaDayView.prototype, {
 	render: function(date) {
 
 		this.start = this.intervalStart = date.clone().stripTime();
-		this.end = this.intervalEnd = this.start.clone().add('days', 1);
+		this.end = this.intervalEnd = this.start.clone().add(1, 'days');
 
 		this.title = this.calendar.formatDate(this.start, this.opt('titleFormat'));
 

+ 2 - 2
src/agenda/AgendaWeekView.js

@@ -17,14 +17,14 @@ $.extend(AgendaWeekView.prototype, {
 
 
 	incrementDate: function(date, delta) {
-		return date.clone().stripTime().add('weeks', delta).startOf('week');
+		return date.clone().stripTime().add(delta, 'weeks').startOf('week');
 	},
 
 
 	render: function(date) {
 
 		this.intervalStart = date.clone().stripTime().startOf('week');
-		this.intervalEnd = this.intervalStart.clone().add('weeks', 1);
+		this.intervalEnd = this.intervalStart.clone().add(1, 'weeks');
 
 		this.start = this.skipHiddenDays(this.intervalStart);
 		this.end = this.skipHiddenDays(this.intervalEnd, -1, true);

+ 2 - 2
src/basic/BasicDayView.js

@@ -16,7 +16,7 @@ $.extend(BasicDayView.prototype, {
 
 
 	incrementDate: function(date, delta) {
-		var out = date.clone().stripTime().add('days', delta);
+		var out = date.clone().stripTime().add(delta, 'days');
 		out = this.skipHiddenDays(out, delta < 0 ? -1 : 1);
 		return out;
 	},
@@ -25,7 +25,7 @@ $.extend(BasicDayView.prototype, {
 	render: function(date) {
 
 		this.start = this.intervalStart = date.clone().stripTime();
-		this.end = this.intervalEnd = this.start.clone().add('days', 1);
+		this.end = this.intervalEnd = this.start.clone().add(1, 'days');
 
 		this.title = this.calendar.formatDate(this.start, this.opt('titleFormat'));
 

+ 2 - 2
src/basic/BasicWeekView.js

@@ -17,14 +17,14 @@ $.extend(BasicWeekView.prototype, {
 
 
 	incrementDate: function(date, delta) {
-		return date.clone().stripTime().add('weeks', delta).startOf('week');
+		return date.clone().stripTime().add(delta, 'weeks').startOf('week');
 	},
 
 
 	render: function(date) {
 
 		this.intervalStart = date.clone().stripTime().startOf('week');
-		this.intervalEnd = this.intervalStart.clone().add('weeks', 1);
+		this.intervalEnd = this.intervalStart.clone().add(1, 'weeks');
 
 		this.start = this.skipHiddenDays(this.intervalStart);
 		this.end = this.skipHiddenDays(this.intervalEnd, -1, true);

+ 4 - 4
src/basic/MonthView.js

@@ -24,7 +24,7 @@ $.extend(MonthView.prototype, {
 
 
 	incrementDate: function(date, delta) {
-		return date.clone().stripTime().add('months', delta).startOf('month');
+		return date.clone().stripTime().add(delta, 'months').startOf('month');
 	},
 
 
@@ -32,7 +32,7 @@ $.extend(MonthView.prototype, {
 		var rowCnt;
 
 		this.intervalStart = date.clone().stripTime().startOf('month');
-		this.intervalEnd = this.intervalStart.clone().add('months', 1);
+		this.intervalEnd = this.intervalStart.clone().add(1, 'months');
 
 		this.start = this.intervalStart.clone();
 		this.start = this.skipHiddenDays(this.start); // move past the first week if no visible days
@@ -41,14 +41,14 @@ $.extend(MonthView.prototype, {
 
 		this.end = this.intervalEnd.clone();
 		this.end = this.skipHiddenDays(this.end, -1, true); // move in from the last week if no visible days
-		this.end.add('days', (7 - this.end.weekday()) % 7); // move to end of week if not already
+		this.end.add((7 - this.end.weekday()) % 7, 'days'); // move to end of week if not already
 		this.end = this.skipHiddenDays(this.end, -1, true); // move in from the last invisible days of the week
 
 		rowCnt = Math.ceil( // need to ceil in case there are hidden days
 			this.end.diff(this.start, 'weeks', true) // returnfloat=true
 		);
 		if (this.isFixedWeeks()) {
-			this.end.add('weeks', 6 - rowCnt);
+			this.end.add(6 - rowCnt, 'weeks');
 			rowCnt = 6;
 		}
 

+ 1 - 1
src/common/DayGrid.limit.js

@@ -287,7 +287,7 @@ $.extend(DayGrid.prototype, {
 			return seg.event;
 		});
 		var dayStart = dayDate.clone().stripTime();
-		var dayEnd = dayStart.clone().add('days', 1);
+		var dayEnd = dayStart.clone().add(1, 'days');
 
 		return this.eventsToSegs(events, dayStart, dayEnd);
 	},

+ 2 - 2
src/common/View.js

@@ -788,14 +788,14 @@ function View(calendar) {
 			// 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 >= nextDayThreshold) {
-				endDay.add('days', 1);
+				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) {
-			endDay = startDay.clone().add('days', 1);
+			endDay = startDay.clone().add(1, 'days');
 		}
 
 		return { start: startDay, end: endDay };