diff --git a/config.js b/config.js index 841979a..6a8d17f 100644 --- a/config.js +++ b/config.js @@ -26,6 +26,10 @@ * sss millisecond 000-999 (456) * 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-time forms: above + T + HH:mm, HH:mm:ss, HH:mm:ss.sss * Any other character is a literal (incl. spaces, tabs, \n). diff --git a/index.html b/index.html index 7427d81..8a354c6 100644 --- a/index.html +++ b/index.html @@ -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;