Add non-standard extension tokens DDD and MMM (localized)
This commit is contained in:
1 parent
0bcb9878b1
commit
d1257bdd2c
2 files changed
+17
No files matched your search
+13
@@ -822,8 +822,15 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({
|
||||
// sss millisecond 000-999 (456)
|
||||
// T literal 'T'
|
||||
// Any other character is a literal (including whitespace).
|
||||
//
|
||||
// Non-standard extension tokens (lookup in i18n dict):
|
||||
// DDD weekday short name (Mon., Tue., ...) from i18n
|
||||
// MMM month short name (January, February, ...) from i18n
|
||||
var result = '';
|
||||
var i = 0;
|
||||
var weekdayKeys = ['Su.', 'Mo.', 'Tu.', 'We.', 'Th.', 'Fr.', 'Sa.'];
|
||||
var monthKeys = ['January', 'February', 'March', 'April', 'May', 'June',
|
||||
'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
while (i < format.length) {
|
||||
var ch = format.charAt(i);
|
||||
if (ch === 'Y' && format.substr(i, 4) === 'YYYY') {
|
||||
@@ -832,9 +839,15 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({
|
||||
} else if (ch === 'Y') {
|
||||
result += date.getFullYear();
|
||||
i += 1;
|
||||
} else if (ch === 'M' && format.substr(i, 3) === 'MMM') {
|
||||
result += t(monthKeys[date.getMonth()]);
|
||||
i += 3;
|
||||
} else if (ch === 'M' && format.substr(i, 2) === 'MM') {
|
||||
result += pad2(date.getMonth() + 1);
|
||||
i += 2;
|
||||
} else if (ch === 'D' && format.substr(i, 3) === 'DDD') {
|
||||
result += t(weekdayKeys[date.getDay()]);
|
||||
i += 3;
|
||||
} else if (ch === 'D' && format.substr(i, 2) === 'DD') {
|
||||
result += pad2(date.getDate());
|
||||
i += 2;
|
||||
|
||||
Reference in new issue
Block a user