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

Merge branch 'fix-moment-iso-string' of https://github.com/joankaradimov/fullcalendar

Adam Shaw 8 лет назад
Родитель
Сommit
fc0614ece2
2 измененных файлов с 7 добавлено и 2 удалено
  1. 2 2
      src/moment-ext.js
  2. 5 0
      tests/automated/moment-ambig.js

+ 2 - 2
src/moment-ext.js

@@ -311,10 +311,10 @@ newMomentProto.format = function() {
 
 newMomentProto.toISOString = function() {
 	if (this._ambigTime) {
-		return oldMomentFormat(this, 'YYYY-MM-DD');
+		return oldMomentFormat(moment(this).locale('en'), 'YYYY-MM-DD');
 	}
 	if (this._ambigZone) {
-		return oldMomentFormat(this, 'YYYY-MM-DD[T]HH:mm:ss');
+		return oldMomentFormat(moment(this).locale('en'), 'YYYY-MM-DD[T]HH:mm:ss');
 	}
 	return oldMomentProto.toISOString.apply(this, arguments);
 };

+ 5 - 0
tests/automated/moment-ambig.js

@@ -26,6 +26,11 @@ describe('ambiguously-zoned moment', function() {
 		expect(mom.toISOString()).toBe('2014-06-08T10:00:00');
 	});
 
+	it('formats via toISOString for locales with non-trivial formatting', function() {
+		var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00').locale('ar');
+		expect(mom.toISOString()).toBe('2014-06-08T10:00:00');
+	});
+
 	it('is correctly cloned', function() {
 		var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
 		var clone = mom.clone();