[FIX] web: allow view with arabic date saving

When editing a form with the arabic language, the date is formatted in
arabic. But the version of the Moment.js library we use for this had
inconsistencies and parsing the arabic date could not work.

Hence, saving would not work since date field values would be invalid.

This commit cherry-pick http://momentjs.com/ commits which solves that:

  from version 1.8.4: https://github.com/moment/moment/commit/c9023b5
  from version 1.9.0: https://github.com/moment/moment/commit/bd328d5

closes #10634
opw-660453
This commit is contained in:
Nicolas Lempereur
2016-01-27 08:42:41 +01:00
parent a576f2baf3
commit b783d2d1c4
25 changed files with 107 additions and 8 deletions
@@ -17,6 +17,10 @@
weekdays : "Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag".split("_"),
weekdaysShort : "Son_Maa_Din_Woe_Don_Vry_Sat".split("_"),
weekdaysMin : "So_Ma_Di_Wo_Do_Vr_Sa".split("_"),
meridiemParse: /vm|nm/i,
isPM : function (input) {
return /^nm$/i.test(input);
},
meridiem : function (hours, minutes, isLower) {
if (hours < 12) {
return isLower ? 'vm' : 'VM';
+5 -1
View File
@@ -48,6 +48,10 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiemParse: /ص|م/,
isPM : function (input) {
return 'م' === input;
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
return "ص";
@@ -79,7 +83,7 @@
yy : "%d سنوات"
},
preparse: function (string) {
return string.replace(/[۰-۹]/g, function (match) {
return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
return numberMap[match];
}).replace(/،/g, ',');
},
+5 -1
View File
@@ -49,6 +49,10 @@
LLL : "D MMMM YYYY LT",
LLLL : "dddd D MMMM YYYY LT"
},
meridiemParse: /ص|م/,
isPM : function (input) {
return 'م' === input;
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
return "ص";
@@ -80,7 +84,7 @@
yy : "%d سنوات"
},
preparse: function (string) {
return string.replace(/[۰-۹]/g, function (match) {
return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
return numberMap[match];
}).replace(/،/g, ',');
},
@@ -72,6 +72,10 @@
y : "bir il",
yy : "%d il"
},
meridiemParse: /gecə|səhər|gündüz|axşam/,
isPM : function (input) {
return /^(gündüz|axşam)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "gecə";
+4 -2
View File
@@ -113,8 +113,10 @@
y : "год",
yy : relativeTimeWithPlural
},
meridiemParse: /ночы|раніцы|дня|вечара/,
isPM : function (input) {
return /^(дня|вечара)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "ночы";
@@ -82,6 +82,10 @@
return symbolMap[match];
});
},
meridiemParse: /রাত|শকাল|দুপুর|বিকেল|রাত/,
isPM: function (input) {
return /^(দুপুর|বিকেল|রাত)$/.test(input);
},
//Bengali is a vast language its spoken
//in different forms in various parts of the world.
//I have just generalized with most common one used
@@ -82,6 +82,10 @@
return symbolMap[match];
});
},
meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
isPM: function (input) {
return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "མཚན་མོ";
@@ -26,6 +26,10 @@
LLL : "D[-an de] MMMM, YYYY LT",
LLLL : "dddd, [la] D[-an de] MMMM, YYYY LT"
},
meridiemParse: /[ap]\.t\.m/i,
isPM: function (input) {
return input.charAt(0).toLowerCase() === 'p';
},
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'p.t.m.' : 'P.T.M.';
@@ -48,6 +48,10 @@
LLL : 'D MMMM YYYY LT',
LLLL : 'dddd, D MMMM YYYY LT'
},
meridiemParse: /قبل از ظهر|بعد از ظهر/,
isPM: function (input) {
return /بعد از ظهر/.test(input);
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
return "قبل از ظهر";
@@ -84,6 +84,11 @@
},
// Hindi notation for meridiems are quite fuzzy in practice. While there exists
// a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
meridiemParse: /रात|सुबह|दोपहर|शाम|रात/,
isPM: function (input) {
// TODO: This is incorrect (look at cutoffs). We need a better isPM interface.
return /^(दोपहर|शाम|रात)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "रात";
@@ -62,6 +62,10 @@
LLL : "YYYY. MMMM D., LT",
LLLL : "YYYY. MMMM D., dddd LT"
},
meridiemParse: /de|du/i,
isPM: function (input) {
return input.charAt(1).toLowerCase() === 'u';
},
meridiem : function (hours, minutes, isLower) {
if (hours < 12) {
return isLower === true ? 'de' : 'DE';
@@ -77,6 +77,10 @@
yy : "%d տարի"
},
meridiemParse: /գիշերվա|առավոտվա|ցերեկվա|երեկոյան/,
isPM: function (input) {
return /^(ցերեկվա|երեկոյան)$/.test(input);
},
meridiem : function (hour) {
if (hour < 4) {
return "գիշերվա";
@@ -25,6 +25,11 @@
LLL : "D MMMM YYYY [pukul] LT",
LLLL : "dddd, D MMMM YYYY [pukul] LT"
},
meridiemParse: /pagi|siang|sore|malam/,
isPM: function (input) {
// TODO: This is incorrect (look at cutoffs).
return /^(siang|sore|malam)$/.test(input);
},
meridiem : function (hours, minutes, isLower) {
if (hours < 11) {
return 'pagi';
@@ -24,6 +24,10 @@
LLL : "YYYY年M月D日LT",
LLLL : "YYYY年M月D日LT dddd"
},
meridiemParse: /午前|午後/i,
isPM : function (input) {
return input === '午後';
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
return "午前";
+4 -4
View File
@@ -27,9 +27,6 @@
LLL : "YYYY년 MMMM D일 LT",
LLLL : "YYYY년 MMMM D일 dddd LT"
},
meridiem : function (hour, minute, isUpper) {
return hour < 12 ? '오전' : '오후';
},
calendar : {
sameDay : '오늘 LT',
nextDay : '내일 LT',
@@ -55,9 +52,12 @@
yy : "%d년"
},
ordinal : '%d일',
meridiemParse : /(오전|오후)/,
meridiemParse : /오전|오후/,
isPM : function (token) {
return token === "오후";
},
meridiem : function (hour, minute, isUpper) {
return hour < 12 ? '오전' : '오후';
}
});
}));
@@ -47,6 +47,10 @@
y : "ഒരു വർഷം",
yy : "%d വർഷം"
},
meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
isPM : function (input) {
return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "രാത്രി";
@@ -82,6 +82,11 @@
return symbolMap[match];
});
},
meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी|रात्री/,
isPM : function (input) {
// TODO: This is wrong.
return /^(दुपारी|सायंकाळी|रात्री)$/.test(input);
},
meridiem: function (hour, minute, isLower)
{
if (hour < 4) {
@@ -24,6 +24,11 @@
LLL : "D MMMM YYYY [pukul] LT",
LLLL : "dddd, D MMMM YYYY [pukul] LT"
},
meridiemParse: /pagi|tengahari|petang|malam/,
isPM: function (input) {
// TODO: This is wrong.
return /^(tengahari|petang|malam)$/.test(input);
},
meridiem : function (hours, minutes, isLower) {
if (hours < 11) {
return 'pagi';
@@ -59,6 +59,11 @@
return symbolMap[match];
});
},
meridiemParse: /राती|बिहान|दिउँसो|बेलुका|साँझ|राती/,
isPM : function (input) {
// TODO: This is wrong.
return /^(दिउँसो|बेलुका|साँझ|राती)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
if (hour < 3) {
return "राती";
@@ -19,6 +19,10 @@
weekdays : "E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë".split("_"),
weekdaysShort : "Die_Hën_Mar_Mër_Enj_Pre_Sht".split("_"),
weekdaysMin : "D_H_Ma_Më_E_P_Sh".split("_"),
meridiemParse: /PD|MD/,
isPM: function (input) {
return input.charAt(0) === 'M';
},
meridiem : function (hours, minutes, isLower) {
return hours < 12 ? 'PD' : 'MD';
},
@@ -89,6 +89,8 @@
// refer http://ta.wikipedia.org/s/1er1
// TODO: This is pretty wrong (when hour is equal to 6 10, 14, 18, 20,
// 24 (0). Also it doesn't split at 12 (noon).
meridiem : function (hour, minute, isLower) {
if (hour >= 6 && hour <= 10) {
return " காலை";
@@ -24,6 +24,10 @@
LLL : "D MMMM YYYY เวลา LT",
LLLL : "วันddddที่ D MMMM YYYY เวลา LT"
},
meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
isPM: function (input) {
return input === 'หลังเที่ยง';
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
return "ก่อนเที่ยง";
@@ -122,6 +122,10 @@
// M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
meridiemParse: /ночі|ранку|дня|вечора/,
isPM: function (input) {
return /^(дня|вечора)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return "ночі";
@@ -29,6 +29,11 @@
lll : "YYYY年MMMD日LT",
llll : "YYYY年MMMD日ddddLT"
},
meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
isPM: function (input) {
// TODO: This is wrong.
return /^(中午|下午|晚上)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
var hm = hour * 100 + minute;
if (hm < 600) {
@@ -28,6 +28,11 @@
lll : "YYYY年MMMD日LT",
llll : "YYYY年MMMD日ddddLT"
},
meridiemParse: /早上|上午|中午|下午|晚上/,
isPM: function (input) {
// TODO: This is wrong.
return /^(中午|下午|晚上)$/.test(input);
},
meridiem : function (hour, minute, isLower) {
var hm = hour * 100 + minute;
if (hm < 900) {