Преглед изворни кода

rename our custom moment time method to avoid collision

Adam Shaw пре 11 година
родитељ
комит
52dab6c1de

+ 2 - 2
src/EventManager.js

@@ -635,10 +635,10 @@ function EventManager(options) { // assumed to be a calendar
 					end = null;
 
 					if (startTime) {
-						start = start.time(startTime);
+						start = start.timeDuration(startTime);
 					}
 					if (endTime) {
-						end = date.clone().time(endTime);
+						end = date.clone().timeDuration(endTime);
 					}
 
 					event = $.extend({}, abstractEvent); // make a copy of the original

+ 4 - 4
src/common/TimeGrid.js

@@ -88,7 +88,7 @@ $.extend(TimeGrid.prototype, {
 
 		// Calculate the time for each slot
 		while (slotTime < this.maxTime) {
-			slotDate = view.start.clone().time(slotTime); // will be in UTC but that's good. to avoid DST issues
+			slotDate = view.start.clone().timeDuration(slotTime); // will be in UTC but that's good. to avoid DST issues
 			minutes = slotDate.minutes();
 
 			axisHtml =
@@ -148,8 +148,8 @@ $.extend(TimeGrid.prototype, {
 
 		for (col = 0; col < view.colCnt; col++) {
 			cellDate = view.cellToDate(0, col); // use the View's cell system for this
-			colStart = cellDate.clone().time(this.minTime);
-			colEnd = cellDate.clone().time(this.maxTime);
+			colStart = cellDate.clone().timeDuration(this.minTime);
+			colEnd = cellDate.clone().timeDuration(this.maxTime);
 			seg = intersectionToSeg(rangeStart, rangeEnd, colStart, colEnd);
 			if (seg) {
 				seg.col = col;
@@ -213,7 +213,7 @@ $.extend(TimeGrid.prototype, {
 
 		return calendar.rezoneDate( // since we are adding a time, it needs to be in the calendar's timezone
 			view.cellToDate(0, cell.col) // View's coord system only accounts for start-of-day for column
-				.time(this.minTime + this.snapDuration * cell.row)
+				.timeDuration(this.minTime + this.snapDuration * cell.row)
 		);
 	},
 

+ 1 - 1
src/common/View.js

@@ -797,7 +797,7 @@ function View(calendar) {
 
 		if (end) {
 			endDay = end.clone().stripTime(); // the beginning of the day the range exclusively ends
-			endTimeMS = +end.time(); // # of milliseconds into `endDay`
+			endTimeMS = +end.timeDuration(); // # 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`.

+ 1 - 1
src/moment-ext.js

@@ -134,7 +134,7 @@ newMomentProto.clone = function() {
 // SETTER
 // You can supply a Duration, a Moment, or a Duration-like argument.
 // When setting the time, and the moment has an ambiguous time, it then becomes unambiguous.
-newMomentProto.time = function(time) {
+newMomentProto.timeDuration = function(time) {
 	if (time == null) { // getter
 		return moment.duration({
 			hours: this.hours(),

+ 1 - 1
src/util.js

@@ -246,7 +246,7 @@ var dayIDs = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ];
 function dayishDiff(a, b) {
 	return moment.duration({
 		days: a.clone().stripTime().diff(b.clone().stripTime(), 'days'),
-		ms: a.time() - b.time()
+		ms: a.timeDuration() - b.timeDuration()
 	});
 }
 

+ 3 - 3
tests/automated/moment-ambig.js

@@ -88,7 +88,7 @@ describe('ambiguously-timed moment', function() {
 
 	it('has a zero time', function() {
 		var mom = $.fullCalendar.moment.parseZone('2014-06-08');
-		var time = mom.time();
+		var time = mom.timeDuration();
 		expect(+time).toBe(0);
 	});
 
@@ -116,9 +116,9 @@ describe('ambiguously-timed moment', function() {
 		var mom = $.fullCalendar.moment.parseZone('2014-06-08');
 		expect(mom.hasTime()).toBe(false);
 		var time = moment.duration({ hours: 1, minutes: 25 });
-		mom.time(time);
+		mom.timeDuration(time);
 		expect(mom.hasTime()).toBe(true);
-		expect(+mom.time()).toBe(+time);
+		expect(+mom.timeDuration()).toBe(+time);
 	});
 
 	it('can be given a time and zone via utc', function() {

+ 7 - 7
tests/automated/moment-misc.js

@@ -7,13 +7,13 @@ describe('FCMoment::time', function() {
 
 		it('should return 00:00 for a moment with 00:00 time', function() {
 			var mom = $.fullCalendar.moment.utc('2014-06-08T00:00:00');
-			var time = mom.time();
+			var time = mom.timeDuration();
 			expect(time).toEqualDuration('00:00');
 		});
 
 		it('should return the time of a moment with a time', function() {
 			var mom = $.fullCalendar.moment.utc('2014-06-08T07:30:00');
-			var time = mom.time();
+			var time = mom.timeDuration();
 			expect(time).toEqualDuration('07:30');
 		});
 	});
@@ -28,21 +28,21 @@ describe('FCMoment::time', function() {
 			it('should give a moment with 00:00 a time', function() {
 				var mom = $.fullCalendar.moment.utc('2014-06-08T00:00:00');
 				var dur = moment.duration('13:25');
-				mom.time(dur);
+				mom.timeDuration(dur);
 				expect(mom).toEqualMoment('2014-06-08T13:25:00+00:00');
 			});
 
 			it('should overwrite the time of a moment with a time', function() {
 				var mom = $.fullCalendar.moment.utc('2014-06-08T05:00:00');
 				var dur = moment.duration('13:25');
-				mom.time(dur);
+				mom.timeDuration(dur);
 				expect(mom).toEqualMoment('2014-06-08T13:25:00+00:00');
 			});
 
 			it('should move to next day if greater than 24 hours', function() {
 				var mom = $.fullCalendar.moment.utc('2014-06-08T00:00:00');
 				var dur = moment.duration('1.01:00:00'); // 1 day, 1 hour
-				mom.time(dur);
+				mom.timeDuration(dur);
 				expect(mom).toEqualMoment('2014-06-09T01:00:00+00:00');
 			});
 		});
@@ -52,14 +52,14 @@ describe('FCMoment::time', function() {
 			it('should give a moment with 00:00 a time', function() {
 				var mom1 = $.fullCalendar.moment.utc('2014-06-09T00:00:00');
 				var mom2 = $.fullCalendar.moment.utc('2014-07-22T05:30:00'); // a Tues, so .days() -> 2
-				mom1.time(mom2);
+				mom1.timeDuration(mom2);
 				expect(mom1).toEqualMoment('2014-06-09T05:30:00+00:00');
 			});
 
 			it('should overwrite the time of a moment with a time', function() {
 				var mom1 = $.fullCalendar.moment.utc('2014-06-09T04:15:00');
 				var mom2 = $.fullCalendar.moment.utc('2014-07-22T05:30:00'); // a Tues, so .days() -> 2
-				mom1.time(mom2);
+				mom1.timeDuration(mom2);
 				expect(mom1).toEqualMoment('2014-06-09T05:30:00+00:00');
 			});
 		});

+ 2 - 2
tests/automated/updateEvent.js

@@ -218,7 +218,7 @@ describe('updateEvent', function() {
 				{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
 			];
 			init();
-			event.start.time('18:00');
+			event.start.timeDuration('18:00');
 			$('#cal').fullCalendar('updateEvent', event);
 			expect(event.allDay).toEqual(false);
 			expect(event.start).toEqualMoment('2014-05-01T18:00:00');
@@ -255,7 +255,7 @@ describe('updateEvent', function() {
 				];
 				init();
 				event.allDay = false;
-				event.start.time('14:00');
+				event.start.timeDuration('14:00');
 				$('#cal').fullCalendar('updateEvent', event);
 				expect(event.allDay).toEqual(false);
 				expect(event.start).toEqualMoment('2014-05-01T14:00:00');

+ 1 - 1
tests/lib/dnd-resize-utils.js

@@ -156,7 +156,7 @@ function testSelection(options, startTime, end, expectSuccess, callback) {
 	end = calendar.moment(end);
 
 	if (startTime) {
-		start.time(startTime);
+		start.timeDuration(startTime);
 		firstDayEl = $('.fc-time-grid .fc-day[data-date="' + start.format('YYYY-MM-DD') + '"]');
 		lastDayEl = $('.fc-time-grid .fc-day[data-date="' + end.format('YYYY-MM-DD') + '"]');
 		firstSlatIndex = start.hours() * 2 + (start.minutes() / 30); // assumes slotDuration:'30:00'