Jelajahi Sumber

fullcalendar moments will always produce english for toISOString and format, called with no args

Adam Shaw 8 tahun lalu
induk
melakukan
13634750b9
1 mengubah file dengan 10 tambahan dan 1 penghapusan
  1. 10 1
      src/moment-ext.js

+ 10 - 1
src/moment-ext.js

@@ -297,16 +297,20 @@ newMomentProto.utcOffset = function(tzo) {
 // -------------------------------------------------------------------------------------------------
 
 newMomentProto.format = function() {
+
 	if (this._fullCalendar && arguments[0]) { // an enhanced moment? and a format string provided?
 		return formatDate(this, arguments[0]); // our extended formatting
 	}
-
 	if (this._ambigTime) {
 		return oldMomentFormat(englishMoment(this), 'YYYY-MM-DD');
 	}
 	if (this._ambigZone) {
 		return oldMomentFormat(englishMoment(this), 'YYYY-MM-DD[T]HH:mm:ss');
 	}
+	if (this._fullCalendar) { // enhanced non-ambig moment?
+		// moment.format() doesn't ensure english, but we want to.
+		return oldMomentFormat(englishMoment(this));
+	}
 
 	return oldMomentProto.format.apply(this, arguments);
 };
@@ -319,6 +323,11 @@ newMomentProto.toISOString = function() {
 	if (this._ambigZone) {
 		return oldMomentFormat(englishMoment(this), 'YYYY-MM-DD[T]HH:mm:ss');
 	}
+	if (this._fullCalendar) { // enhanced non-ambig moment?
+		// depending on browser, moment might not output english. ensure english.
+		// https://github.com/moment/moment/blob/2.18.1/src/lib/moment/format.js#L22
+		return oldMomentProto.toISOString.apply(englishMoment(this), arguments);
+	}
 
 	return oldMomentProto.toISOString.apply(this, arguments);
 };