diff --git a/config.js b/config.js index a58554a..96c56f8 100644 --- a/config.js +++ b/config.js @@ -24,6 +24,10 @@ * mm minute 00-59 (35) - lowercase! * ss second 00-59 (22) - lowercase! * sss millisecond 000-999 (456) + * a am/pm (lowercase) (pm) + * A AM/PM (uppercase) (PM) + * aaaa am/pm lowercase (pm) - long form + * AAAA AM/PM uppercase (PM) - long form * T literal 'T' * * Non-standard extension tokens (localized via i18n): diff --git a/index.html b/index.html index b4a326b..80d6d3e 100644 --- a/index.html +++ b/index.html @@ -897,6 +897,22 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({ } else if (ch === 's' && format.substr(i, 2) === 'ss') { result += pad2(date.getSeconds()); i += 2; + } else if (ch === 'a' && format.substr(i, 4) === 'aaaa') { + // Full am/pm text (lowercase) + result += date.getHours() < 12 ? 'am' : 'pm'; + i += 4; + } else if (ch === 'A' && format.substr(i, 4) === 'AAAA') { + // Full AM/PM text (uppercase) + result += date.getHours() < 12 ? 'AM' : 'PM'; + i += 4; + } else if (ch === 'a') { + // am/pm (lowercase) + result += date.getHours() < 12 ? 'am' : 'pm'; + i += 1; + } else if (ch === 'A') { + // AM/PM (uppercase) + result += date.getHours() < 12 ? 'AM' : 'PM'; + i += 1; } else { result += ch; i += 1;