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
@@ -26,6 +26,10 @@
|
|||||||
* sss millisecond 000-999 (456)
|
* sss millisecond 000-999 (456)
|
||||||
* T literal 'T'
|
* T literal 'T'
|
||||||
*
|
*
|
||||||
|
* Non-standard extension tokens (localized via i18n):
|
||||||
|
* DDD weekday short name (Mon., Tue., ...)
|
||||||
|
* MMM month short name (January, February, ...)
|
||||||
|
*
|
||||||
* Date-only forms: YYYY, YYYY-MM, YYYY-MM-DD
|
* Date-only forms: YYYY, YYYY-MM, YYYY-MM-DD
|
||||||
* Date-time forms: above + T + HH:mm, HH:mm:ss, HH:mm:ss.sss
|
* Date-time forms: above + T + HH:mm, HH:mm:ss, HH:mm:ss.sss
|
||||||
* Any other character is a literal (incl. spaces, tabs, \n).
|
* Any other character is a literal (incl. spaces, tabs, \n).
|
||||||
|
|||||||
+13
@@ -822,8 +822,15 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({
|
|||||||
// sss millisecond 000-999 (456)
|
// sss millisecond 000-999 (456)
|
||||||
// T literal 'T'
|
// T literal 'T'
|
||||||
// Any other character is a literal (including whitespace).
|
// 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 result = '';
|
||||||
var i = 0;
|
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) {
|
while (i < format.length) {
|
||||||
var ch = format.charAt(i);
|
var ch = format.charAt(i);
|
||||||
if (ch === 'Y' && format.substr(i, 4) === 'YYYY') {
|
if (ch === 'Y' && format.substr(i, 4) === 'YYYY') {
|
||||||
@@ -832,9 +839,15 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({
|
|||||||
} else if (ch === 'Y') {
|
} else if (ch === 'Y') {
|
||||||
result += date.getFullYear();
|
result += date.getFullYear();
|
||||||
i += 1;
|
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') {
|
} else if (ch === 'M' && format.substr(i, 2) === 'MM') {
|
||||||
result += pad2(date.getMonth() + 1);
|
result += pad2(date.getMonth() + 1);
|
||||||
i += 2;
|
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') {
|
} else if (ch === 'D' && format.substr(i, 2) === 'DD') {
|
||||||
result += pad2(date.getDate());
|
result += pad2(date.getDate());
|
||||||
i += 2;
|
i += 2;
|
||||||
|
|||||||
Reference in new issue
Block a user