From a0a31cd6483b0531eb349770faa447908626c61d Mon Sep 17 00:00:00 2001 From: Borgar Date: Mon, 5 Oct 2026 14:38:53 +0000 Subject: [PATCH 1/3] Support x-sysdate/x-systime directives --- lib/codeToLocale.ts | 192 +++++++-------- lib/formatNumber.ts | 11 +- lib/index.ts | 43 +--- lib/locale.ts | 10 + lib/locales.ts | 328 +++++++++++++++++++------ lib/parseFormatSection.ts | 37 ++- lib/parseLocaleInstr.ts | 133 ++++++++++ lib/prepareFormatterData.ts | 48 ++++ lib/types.ts | 4 +- test/parseLocaleInstr.spec.ts | 249 +++++++++++++++++++ test/sysdate.spec.ts | 451 ++++++++++++++++++++++++++++++++++ 11 files changed, 1277 insertions(+), 229 deletions(-) create mode 100644 lib/parseLocaleInstr.ts create mode 100644 lib/prepareFormatterData.ts create mode 100644 test/parseLocaleInstr.spec.ts create mode 100644 test/sysdate.spec.ts diff --git a/lib/codeToLocale.ts b/lib/codeToLocale.ts index 0742f21..ba08642 100644 --- a/lib/codeToLocale.ts +++ b/lib/codeToLocale.ts @@ -4,89 +4,89 @@ export const codeToLocale: Readonly> = Object.freeze({ 1078: 'af', // Afrikaans 1052: 'sq', // Albanian 1118: 'am', // Amharic - 5121: 'ar_DZ', // Arabic - Algeria - 15361: 'ar_BH', // Arabic - Bahrain - 3073: 'ar_EG', // Arabic - Egypt - 2049: 'ar_IQ', // Arabic - Iraq - 11265: 'ar_JO', // Arabic - Jordan - 13313: 'ar_KW', // Arabic - Kuwait - 12289: 'ar_LB', // Arabic - Lebanon - 4097: 'ar_LY', // Arabic - Libya - 6145: 'ar_MA', // Arabic - Morocco - 8193: 'ar_OM', // Arabic - Oman - 16385: 'ar_QA', // Arabic - Qatar - 1025: 'ar_SA', // Arabic - Saudi Arabia - 10241: 'ar_SY', // Arabic - Syria - 7169: 'ar_TN', // Arabic - Tunisia - 14337: 'ar_AE', // Arabic - United Arab Emirates - 9217: 'ar_YE', // Arabic - Yemen + 5121: 'ar-DZ', // Arabic - Algeria + 15361: 'ar-BH', // Arabic - Bahrain + 3073: 'ar-EG', // Arabic - Egypt + 2049: 'ar-IQ', // Arabic - Iraq + 11265: 'ar-JO', // Arabic - Jordan + 13313: 'ar-KW', // Arabic - Kuwait + 12289: 'ar-LB', // Arabic - Lebanon + 4097: 'ar-LY', // Arabic - Libya + 6145: 'ar-MA', // Arabic - Morocco + 8193: 'ar-OM', // Arabic - Oman + 16385: 'ar-QA', // Arabic - Qatar + 1025: 'ar-SA', // Arabic - Saudi Arabia + 10241: 'ar-SY', // Arabic - Syria + 7169: 'ar-TN', // Arabic - Tunisia + 14337: 'ar-AE', // Arabic - United Arab Emirates + 9217: 'ar-YE', // Arabic - Yemen 1067: 'hy', // Armenian 1101: 'as', // Assamese - 2092: 'az_AZ', // Azeri - Cyrillic - 1068: 'az_AZ', // Azeri - Latin + 2092: 'az-AZ', // Azeri - Cyrillic + 1068: 'az-AZ', // Azeri - Latin 1069: 'eu', // Basque 1059: 'be', // Belarusian 2117: 'bn', // Bengali - Bangladesh - 1093: 'bn_IN', // Bengali - India + 1093: 'bn-IN', // Bengali - India 5146: 'bs', // Bosnian 1026: 'bg', // Bulgarian 1109: 'my', // Burmese 1027: 'ca', // Catalan - 2052: 'zh_CN', // Chinese - China - 3076: 'zh_HK', // Chinese - Hong Kong SAR - 5124: 'zh_MO', // Chinese - Macau SAR - 4100: 'zh_SG', // Chinese - Singapore - 1028: 'zh_TW', // Chinese - Taiwan + 2052: 'zh-CN', // Chinese - China + 3076: 'zh-HK', // Chinese - Hong Kong SAR + 5124: 'zh-MO', // Chinese - Macau SAR + 4100: 'zh-SG', // Chinese - Singapore + 1028: 'zh-TW', // Chinese - Taiwan 1050: 'hr', // Croatian 1029: 'cs', // Czech 1030: 'da', // Danish 1125: 'dv', // Divehi; Dhivehi; Maldivian - 2067: 'nl_BE', // Dutch - Belgium - 1043: 'nl_NL', // Dutch - Netherlands + 2067: 'nl-BE', // Dutch - Belgium + 1043: 'nl-NL', // Dutch - Netherlands 1126: 'bin', // Edo - 3081: 'en_AU', // English - Australia - 10249: 'en_BZ', // English - Belize - 4105: 'en_CA', // English - Canada - 9225: 'en_CB', // English - Caribbean - 2057: 'en_GB', // English - Great Britain - 16393: 'en_IN', // English - India - 6153: 'en_IE', // English - Ireland - 8201: 'en_JM', // English - Jamaica - 5129: 'en_NZ', // English - New Zealand - 13321: 'en_PH', // English - Phillippines - 7177: 'en_ZA', // English - Southern Africa - 11273: 'en_TT', // English - Trinidad - 1033: 'en_US', // English - United States - 12297: 'en_ZW', // English - Zimbabwe + 3081: 'en-AU', // English - Australia + 10249: 'en-BZ', // English - Belize + 4105: 'en-CA', // English - Canada + 9225: 'en-CB', // English - Caribbean + 2057: 'en-GB', // English - Great Britain + 16393: 'en-IN', // English - India + 6153: 'en-IE', // English - Ireland + 8201: 'en-JM', // English - Jamaica + 5129: 'en-NZ', // English - New Zealand + 13321: 'en-PH', // English - Phillippines + 7177: 'en-ZA', // English - Southern Africa + 11273: 'en-TT', // English - Trinidad + 1033: 'en-US', // English - United States + 12297: 'en-ZW', // English - Zimbabwe 1061: 'et', // Estonian 1071: 'mk', // FYRO Macedonia 1080: 'fo', // Faroese 1065: 'fa', // Farsi - Persian 1124: 'fil', // Filipino 1035: 'fi', // Finnish - 2060: 'fr_BE', // French - Belgium - 11276: 'fr_CM', // French - Cameroon - 3084: 'fr_CA', // French - Canada - 9228: 'fr_CG', // French - Congo - 12300: 'fr_CI', // French - Cote d'Ivoire - 1036: 'fr_FR', // French - France - 5132: 'fr_LU', // French - Luxembourg - 13324: 'fr_ML', // French - Mali - 6156: 'fr_MC', // French - Monaco - 14348: 'fr_MA', // French - Morocco - 10252: 'fr_SN', // French - Senegal - 4108: 'fr_CH', // French - Switzerland + 2060: 'fr-BE', // French - Belgium + 11276: 'fr-CM', // French - Cameroon + 3084: 'fr-CA', // French - Canada + 9228: 'fr-CG', // French - Congo + 12300: 'fr-CI', // French - Cote d'Ivoire + 1036: 'fr-FR', // French - France + 5132: 'fr-LU', // French - Luxembourg + 13324: 'fr-ML', // French - Mali + 6156: 'fr-MC', // French - Monaco + 14348: 'fr-MA', // French - Morocco + 10252: 'fr-SN', // French - Senegal + 4108: 'fr-CH', // French - Switzerland 7180: 'fr', // French - West Indies - 1122: 'fy_NL', // Frisian - Netherlands - 2108: 'gd_IE', // Gaelic - Ireland + 1122: 'fy-NL', // Frisian - Netherlands + 2108: 'gd-IE', // Gaelic - Ireland 1084: 'gd', // Gaelic - Scotland 1110: 'gl', // Galician 1079: 'ka', // Georgian - 3079: 'de_AT', // German - Austria - 1031: 'de_DE', // German - Germany - 5127: 'de_LI', // German - Liechtenstein - 4103: 'de_LU', // German - Luxembourg - 2055: 'de_CH', // German - Switzerland + 3079: 'de-AT', // German - Austria + 1031: 'de-DE', // German - Germany + 5127: 'de-LI', // German - Liechtenstein + 4103: 'de-LU', // German - Luxembourg + 2055: 'de-CH', // German - Switzerland 1032: 'el', // Greek 1140: 'gn', // Guarani - Paraguay 1095: 'gu', // Gujarati @@ -95,10 +95,10 @@ export const codeToLocale: Readonly> = Object.freeze({ 1081: 'hi', // Hindi 1038: 'hu', // Hungarian 1039: 'is', // Icelandic - 1136: 'ig_NG', // Igbo - Nigeria + 1136: 'ig-NG', // Igbo - Nigeria 1057: 'id', // Indonesian - 1040: 'it_IT', // Italian - Italy - 2064: 'it_CH', // Italian - Switzerland + 1040: 'it-IT', // Italian - Italy + 2064: 'it-CH', // Italian - Switzerland 1041: 'ja', // Japanese 1099: 'kn', // Kannada 1120: 'ks', // Kashmiri @@ -111,8 +111,8 @@ export const codeToLocale: Readonly> = Object.freeze({ 1142: 'la', // Latin 1062: 'lv', // Latvian 1063: 'lt', // Lithuanian - 2110: 'ms_BN', // Malay - Brunei - 1086: 'ms_MY', // Malay - Malaysia + 2110: 'ms-BN', // Malay - Brunei + 1086: 'ms-MY', // Malay - Malaysia 1100: 'ml', // Malayalam 1082: 'mt', // Maltese 1112: 'mni', // Manipuri @@ -121,22 +121,22 @@ export const codeToLocale: Readonly> = Object.freeze({ 1104: 'mn', // Mongolian 2128: 'mn', // Mongolian 1121: 'ne', // Nepali - 1044: 'no_NO', // Norwegian - Bokml - 2068: 'no_NO', // Norwegian - Nynorsk + 1044: 'no-NO', // Norwegian - Bokml + 2068: 'no-NO', // Norwegian - Nynorsk 1096: 'or', // Oriya 1045: 'pl', // Polish - 1046: 'pt_BR', // Portuguese - Brazil - 2070: 'pt_PT', // Portuguese - Portugal + 1046: 'pt-BR', // Portuguese - Brazil + 2070: 'pt-PT', // Portuguese - Portugal 1094: 'pa', // Punjabi 1047: 'rm', // Raeto-Romance - 2072: 'ro_MO', // Romanian - Moldova - 1048: 'ro_RO', // Romanian - Romania + 2072: 'ro-MO', // Romanian - Moldova + 1048: 'ro-RO', // Romanian - Romania 1049: 'ru', // Russian - 2073: 'ru_MO', // Russian - Moldova + 2073: 'ru-MO', // Russian - Moldova 1083: 'se', // Sami Lappish 1103: 'sa', // Sanskrit - 3098: 'sr_SP', // Serbian - Cyrillic - 2074: 'sr_SP', // Serbian - Latin + 3098: 'sr-SP', // Serbian - Cyrillic + 2074: 'sr-SP', // Serbian - Latin 1072: 'st', // Sesotho (Sutu) 1074: 'tn', // Setsuana 1113: 'sd', // Sindhi @@ -145,28 +145,28 @@ export const codeToLocale: Readonly> = Object.freeze({ 1060: 'sl', // Slovenian 1143: 'so', // Somali 1070: 'sb', // Sorbian - 11274: 'es_AR', // Spanish - Argentina - 16394: 'es_BO', // Spanish - Bolivia - 13322: 'es_CL', // Spanish - Chile - 9226: 'es_CO', // Spanish - Colombia - 5130: 'es_CR', // Spanish - Costa Rica - 7178: 'es_DO', // Spanish - Dominican Republic - 12298: 'es_EC', // Spanish - Ecuador - 17418: 'es_SV', // Spanish - El Salvador - 4106: 'es_GT', // Spanish - Guatemala - 18442: 'es_HN', // Spanish - Honduras - 2058: 'es_MX', // Spanish - Mexico - 19466: 'es_NI', // Spanish - Nicaragua - 6154: 'es_PA', // Spanish - Panama - 15370: 'es_PY', // Spanish - Paraguay - 10250: 'es_PE', // Spanish - Peru - 20490: 'es_PR', // Spanish - Puerto Rico - 1034: 'es_ES', // Spanish - Spain (Traditional) - 14346: 'es_UY', // Spanish - Uruguay - 8202: 'es_VE', // Spanish - Venezuela + 11274: 'es-AR', // Spanish - Argentina + 16394: 'es-BO', // Spanish - Bolivia + 13322: 'es-CL', // Spanish - Chile + 9226: 'es-CO', // Spanish - Colombia + 5130: 'es-CR', // Spanish - Costa Rica + 7178: 'es-DO', // Spanish - Dominican Republic + 12298: 'es-EC', // Spanish - Ecuador + 17418: 'es-SV', // Spanish - El Salvador + 4106: 'es-GT', // Spanish - Guatemala + 18442: 'es-HN', // Spanish - Honduras + 2058: 'es-MX', // Spanish - Mexico + 19466: 'es-NI', // Spanish - Nicaragua + 6154: 'es-PA', // Spanish - Panama + 15370: 'es-PY', // Spanish - Paraguay + 10250: 'es-PE', // Spanish - Peru + 20490: 'es-PR', // Spanish - Puerto Rico + 1034: 'es-ES', // Spanish - Spain (Traditional) + 14346: 'es-UY', // Spanish - Uruguay + 8202: 'es-VE', // Spanish - Venezuela 1089: 'sw', // Swahili - 2077: 'sv_FI', // Swedish - Finland - 1053: 'sv_SE', // Swedish - Sweden + 2077: 'sv-FI', // Swedish - Finland + 1053: 'sv-SE', // Swedish - Sweden 1114: 'syc', // Syriac 1064: 'tg', // Tajik 1097: 'ta', // Tamil @@ -179,8 +179,8 @@ export const codeToLocale: Readonly> = Object.freeze({ 1090: 'tk', // Turkmen 1058: 'uk', // Ukrainian 1056: 'ur', // Urdu - 2115: 'uz_UZ', // Uzbek - Cyrillic - 1091: 'uz_UZ', // Uzbek - Latin + 2115: 'uz-UZ', // Uzbek - Cyrillic + 1091: 'uz-UZ', // Uzbek - Latin 1075: 've', // Venda 1066: 'vi', // Vietnamese 1106: 'cy', // Welsh diff --git a/lib/formatNumber.ts b/lib/formatNumber.ts index 17a8940..563b94f 100644 --- a/lib/formatNumber.ts +++ b/lib/formatNumber.ts @@ -2,6 +2,7 @@ import { TOKEN_TEXT, indexColors } from './constants.ts'; import { defaultLocale, getLocale } from './locale.ts'; import type { FormatOptions } from './options.ts'; import { parseFormatSection } from './parseFormatSection.ts'; +import { prepareFormatterData } from './prepareFormatterData.ts'; import { runPart } from './runPart.ts'; import type { Partition, PatternParseData } from './types.ts'; @@ -88,6 +89,14 @@ export function formatValue ( } // find and run the pattern part that applies to this number const v = value as number | string | bigint; - const part = getPart(v, parts); + let part = getPart(v, parts); + if (part?.sysdate) { + const syspattern = l10n?.sysdate ?? 'dd mmmm yyyy'; + part = prepareFormatterData(syspattern, false).partitions[0]; + } + if (part?.systime) { + const syspattern = l10n?.systime ?? 'hh:mm:ss'; + part = prepareFormatterData(syspattern, false).partitions[0]; + } return part ? runPart(v, part, opts, l10n) : opts.overflow; } diff --git a/lib/index.ts b/lib/index.ts index 86fe189..903dcd2 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -7,8 +7,6 @@ * @module numfmt */ -import { TOKEN_ERROR } from './constants.ts'; - export { getLocale, parseLocale, @@ -35,7 +33,8 @@ export { TOKEN_GENERAL, TOKEN_HASH, TOKEN_ZERO, TOKEN_QMARK, TOKEN_SLASH, TOKEN_GROUP, TOKEN_SCALE, TOKEN_COMMA, TOKEN_BREAK, TOKEN_TEXT, TOKEN_PLUS, TOKEN_MINUS, TOKEN_POINT, TOKEN_SPACE, TOKEN_PERCENT, TOKEN_DIGIT, TOKEN_CALENDAR, TOKEN_ERROR, TOKEN_DATETIME, TOKEN_DURATION, TOKEN_CONDITION, TOKEN_DBNUM, TOKEN_NATNUM, TOKEN_LOCALE, TOKEN_COLOR, - TOKEN_MODIFIER, TOKEN_AMPM, TOKEN_ESCAPED, TOKEN_STRING, TOKEN_SKIP, TOKEN_EXP, TOKEN_FILL, TOKEN_PAREN, TOKEN_CHAR + TOKEN_MODIFIER, TOKEN_AMPM, TOKEN_ESCAPED, TOKEN_STRING, TOKEN_SKIP, TOKEN_EXP, TOKEN_FILL, TOKEN_PAREN, TOKEN_CHAR, + TOKEN_CURRENCY } from './constants.ts'; import { dateToSerial as handleDates } from './serialDate.ts'; @@ -43,7 +42,7 @@ export { dateToSerial, dateFromSerial } from './serialDate.ts'; export type { LocaleData, LocalFormat, LocaleToken, MonthNames, DayNames } from './locale.ts'; -export type { ParseDataBool, ParseDataNum } from './parseValue/types.ts'; +export type { ParseDataBool, ParseDataNum, ParseValueOptions } from './parseValue/types.ts'; export { parseNumber } from './parseValue/parseNumber.ts'; export { parseDate } from './parseValue/parseDate.ts'; export { parseTime } from './parseValue/parseTime.ts'; @@ -52,44 +51,12 @@ export { parseValue } from './parseValue/parseValue.ts'; import { formatColor as fmtColor, formatValue as fmtValue } from './formatNumber.ts'; import { info, dateInfo, isDate, isPercent, isText } from './formatInfo.ts'; -import { parsePattern } from './parsePattern.ts'; -import type { FormatDateInfo, FormatInfo, PatternParseData } from './types.ts'; -import { createPartition } from './createPartition.ts'; +import type { FormatDateInfo, FormatInfo } from './types.ts'; +import { prepareFormatterData } from './prepareFormatterData.ts'; export { tokenize } from './tokenize.ts'; export { getFormatFromId } from './getFormatFromId.ts'; -type CacheData = PatternParseData & { dateInfo?: FormatDateInfo, info?: FormatInfo }; -const _parseDataCache = new Map(); -function prepareFormatterData (pattern: string, shouldThrow = false): CacheData { - if (!pattern) { pattern = 'General'; } - - let parseData = _parseDataCache.get(pattern); - if (!parseData) { - try { - parseData = parsePattern(pattern); - _parseDataCache.set(pattern, parseData); - } - catch (err) { - // if the options say to throw errors, then do so - if (shouldThrow) { - throw err; - } - // else we set the parsedata to error - const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : 'Unknown error'; - const errPart = createPartition([ { type: TOKEN_ERROR } ]); - errPart.error = true; - parseData = { - pattern: pattern, - partitions: [ errPart, errPart, errPart, errPart ], - error: message, - locale: undefined - }; - } - } - return parseData; -} - /** * Formats a value as a string and returns the result. * diff --git a/lib/locale.ts b/lib/locale.ts index bc308d5..9939896 100644 --- a/lib/locale.ts +++ b/lib/locale.ts @@ -264,6 +264,16 @@ export type LocaleData = { * Instructive properties on how formats should be constructed. */ format?: LocalFormat; + /** + * A format pattern to use when [$-x-sysdate] is found in a pattern. + * @default "dd mmmm yyyy" + */ + sysdate?: string; + /** + * A format pattern to use when [$-x-systime] is found in a pattern. + * @default "hh:mm:ss" + */ + systime?: string; }; /** diff --git a/lib/locales.ts b/lib/locales.ts index 4c85800..70076fd 100644 --- a/lib/locales.ts +++ b/lib/locales.ts @@ -143,7 +143,9 @@ export function initLocales () { }, general: 'G/通用格式', currency: '¥', - format: xf({ h: 0, d: 0, f: 0, m: 0, o: 2, s: 1 }) + format: xf({ h: 0, d: 0, f: 0, m: 0, o: 2, s: 1 }), + sysdate: 'yyyy年m月d日', + systime: 'h:mm:ss' }, 'zh-CN'); addLocale({ group: ',', @@ -157,7 +159,9 @@ export function initLocales () { colors: _zhCl, general: 'G/通用格式', currency: 'NT$', - format: xf({ d: 0, f: 0, o: 2, m: 0, i: 1 }) + format: xf({ d: 0, f: 0, o: 2, m: 0, i: 1 }), + sysdate: 'yyyy年m月d日', + systime: 'AM/PM hh:mm:ss' }, 'zh-TW'); addLocale({ group: ',', @@ -169,7 +173,9 @@ export function initLocales () { color: '色彩', colors: _zhCl, currency: 'HK$', - format: xf({ h: 0, d: 0, f: 0, m: 0, p: 1 }) + format: xf({ h: 0, d: 0, f: 0, m: 0, p: 1 }), + sysdate: 'yyyy年m月d日', + systime: 'h:mm:ss' }, 'zh-HK'); addLocale({ @@ -192,7 +198,9 @@ export function initLocales () { 紫: C_MAGENTA, 水: C_CYAN }, - format: xf({ h: 0, f: 0, o: 2, d: 1 }) + format: xf({ h: 0, f: 0, o: 2, d: 1 }), + sysdate: 'yyyy年m月d日', + systime: 'h:mm:ss' }, 'ja'); addLocale({ @@ -215,7 +223,9 @@ export function initLocales () { }, general: 'G/표준', currency: '₩', - format: xf({ h: 0, f: 0, o: 2, k: '-' }) + format: xf({ h: 0, f: 0, o: 2, k: '-' }), + sysdate: 'yyyy년 mmmm d일 dddd', + systime: 'AM/PM h:mm:ss' }, 'ko'); addLocale({ @@ -237,7 +247,9 @@ export function initLocales () { ฟ้า: C_CYAN }, currency: '฿', - format: xf({ h: 0, d: 0, f: 0, m: 0, o: 1 }) + format: xf({ h: 0, d: 0, f: 0, m: 0, o: 1 }), + sysdate: 'd mmmm yyyy', + systime: 'h:mm:ss' }, 'th'); addLocale(xm({ @@ -261,7 +273,9 @@ export function initLocales () { general: 'Všeobecný', opcodes: { dy: 'r' }, currency: 'Kč', - format: xf({ h: 0, k: '.', l: '.' }) + format: xf({ h: 0, k: '.', l: '.' }), + sysdate: 'dddd d. mmmm yyyy', + systime: 'h:mm:ss' }, -1, 2), 'cs'); addLocale(xm({ @@ -284,7 +298,9 @@ export function initLocales () { general: 'Standard', opcodes: { dy: 'å', th: 't' }, currency: 'kr.', - format: xf({ k: '-' }) + format: xf({ k: '-' }), + sysdate: 'd. mmmm yyyy', + systime: 'hh:mm:ss' }, 3, 2), 'da'); addLocale(xm({ @@ -309,21 +325,55 @@ export function initLocales () { general: 'Standaard', opcodes: { dy: 'j', th: 'u' }, currency: '€', - format: xf({ d: 0, f: 2, m: 0, k: '-', s: 1 }) + format: xf({ d: 0, f: 2, m: 0, k: '-', s: 1 }), + sysdate: 'dddd d mmmm yyyy', + systime: 'hh:mm:ss' }, -1, 2), 'nl'); - addLocale({ group: ',', format: xf({ h: 0, d: 0, f: 0, m: 0, o: 0, p: 1 }) }, 'en'); - addLocale({ group: ',', format: xf({ h: 0, d: 0, f: 0, m: 0, o: 0, p: 1 }) }, 'en-US'); - addLocale({ group: ',', format: xf({ h: 0, f: 0, o: 2, p: 0, k: '-' }) }, 'en-CA'); - addLocale({ group: ',', color: 'Colour', ampm: [ 'AM', 'PM' ], format: xf({ h: 0, d: 0, f: 0, p: 0 }) }, 'en-AU'); - addLocale({ group: ',', color: 'Colour', ampm: [ 'AM', 'PM' ], currency: '£', format: xf({ f: 0, p: 0 }) }, 'en-GB'); + addLocale({ + group: ',', + format: xf({ h: 0, d: 0, f: 0, m: 0, o: 0, p: 1 }), + sysdate: 'dddd, mmmm d, yyyy', + systime: 'h:mm:ss AM/PM' + }, 'en'); + addLocale({ + group: ',', + format: xf({ h: 0, d: 0, f: 0, m: 0, o: 0, p: 1 }), + sysdate: 'dddd, mmmm d, yyyy', + systime: 'h:mm:ss AM/PM' + }, 'en-US'); + addLocale({ + group: ',', + format: xf({ h: 0, f: 0, o: 2, p: 0, k: '-' }), + sysdate: 'mmmm d, yyyy', + systime: 'h:mm:ss AM/PM' + }, 'en-CA'); + addLocale({ + group: ',', + color: 'Colour', + ampm: [ 'AM', 'PM' ], + format: xf({ h: 0, d: 0, f: 0, p: 0 }), + sysdate: 'dddd, d mmmm yyyy', + systime: 'h:mm:ss AM/PM' + }, 'en-AU'); + addLocale({ + group: ',', + color: 'Colour', + ampm: [ 'AM', 'PM' ], + currency: '£', + format: xf({ f: 0, p: 0 }), + sysdate: 'dd mmmm yyyy', + systime: 'hh:mm:ss' + }, 'en-GB'); addLocale({ group: ',', mmm: _M('Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sept;Oct;Nov;Dec'), color: 'Colour', ampm: [ 'am', 'pm' ], currency: '€', - format: xf({ f: 0, p: 0 }) + format: xf({ f: 0, p: 0 }), + sysdate: 'dddd d mmmm yyyy', + systime: 'hh:mm:ss' }, 'en-IE'); addLocale(xm({ @@ -348,7 +398,9 @@ export function initLocales () { general: 'Yleinen', currency: '€', opcodes: { dy: 'v', dm: 'k', dd: 'p', th: 't' }, - format: xf({ h: 0, d: 0, p: 0, k: '.', l: '.', m: 0, c: 1 }) + format: xf({ h: 0, d: 0, p: 0, k: '.', l: '.', m: 0, c: 1 }), + sysdate: 'dddd d. mmmm yyyy', + systime: 'h.mm.ss' }, -1, 2), 'fi'); const _fr = xm({ @@ -371,11 +423,29 @@ export function initLocales () { cyan: C_CYAN }, opcodes: { dy: 'a', dd: 'j', wd: 'o' }, - general: 'Standard' + general: 'Standard', + systime: 'hh:mm:ss' }, -1, -13); - addLocale({ ..._fr, currency: '€', format: xf({}) }, 'fr'); - addLocale({ ..._fr, ampm: [ 'a.m.', 'p.m.' ], format: xf({ p: 1, o: 2, d: 1, k: '-', l: '-', s: 1 }) }, 'fr-CA'); - addLocale({ group: "'", decimal: '.', ..._fr, currency: 'CHF', format: xf({ o: 1, d: 1, k: '.', l: '.' }) }, 'fr-CH'); + addLocale({ + ..._fr, + currency: '€', + format: xf({}), + sysdate: 'dddd d mmmm yyyy' + }, 'fr'); + addLocale({ + ..._fr, + ampm: [ 'a.m.', 'p.m.' ], + format: xf({ p: 1, o: 2, d: 1, k: '-', l: '-', s: 1 }), + sysdate: 'd mmmm yyyy' + }, 'fr-CA'); + addLocale({ + group: "'", + decimal: '.', + ..._fr, + currency: 'CHF', + format: xf({ o: 1, d: 1, k: '.', l: '.' }), + sysdate: 'dddd, d mmmm yyyy' + }, 'fr-CH'); const _de = xm({ mmmm: _M('Januar;Februar;März;April;Mai;Juni;Juli;August;September;Oktober;November;Dezember'), @@ -394,7 +464,9 @@ export function initLocales () { zyan: C_CYAN }, opcodes: { dy: 'j', dd: 't' }, - general: 'Standard' + general: 'Standard', + sysdate: 'dddd, d. mmmm yyyy', + systime: 'hh:mm:ss' }, -1, 2); addLocale({ group: '.', decimal: ',', ..._de, currency: '€', format: xf({ k: '.', l: '. ' }) }, 'de'); addLocale({ group: '’', decimal: '.', ..._de, currency: 'CHF', mmm: _M('Jan;Feb;Mär;Apr;Mai;Jun;Jul;Aug;Sep;Okt;Nov;Dez'), format: xf({ o: 1, d: 1, k: '.', f: 2, s: 1, l: '. ' }) }, 'de-CH'); @@ -421,7 +493,9 @@ export function initLocales () { color: 'Χρώμα', opcodes: { dy: 'ε', dm: 'μ', dd: 'η', th: 'ω', tm: 'λ', ts: 'δ' }, currency: '€', - format: xf({ h: 0, d: 0, m: 0 }) + format: xf({ h: 0, d: 0, m: 0 }), + sysdate: 'dddd, d mmmm yyyy', + systime: 'h:mm:ss AM/PM' }, -1, 3), 'el'); addLocale({ @@ -446,7 +520,9 @@ export function initLocales () { ciánkék: C_CYAN }, color: 'Szín', - format: xf({ h: 0, o: 2, k: '.', l: '.', d: 1 }) + format: xf({ h: 0, o: 2, k: '.', l: '.', d: 1 }), + sysdate: 'yyyy. mmmm d".", dddd', // XXX: Illegal format!? + systime: 'h:mm:ss' }, 'hu'); addLocale(xm({ @@ -456,7 +532,9 @@ export function initLocales () { mmmm: _M('janúar;febrúar;mars;apríl;maí;júní;júlí;ágúst;september;október;nóvember;desember'), dddd: _W('sunnu~;mánu~;þriðju~;miðviku~;fimmtu~;föstu~;laugar~', 'dagur'), currency: 'kr.', - format: xf({ d: 0, m: 0, k: '.', l: '.' }) + format: xf({ d: 0, m: 0, k: '.', l: '.' }), + sysdate: 'dddd, d. mmmm yyyy', + systime: 'hh:mm:ss' }, 3, 3), 'is'); addLocale(xm({ @@ -478,7 +556,9 @@ export function initLocales () { sian: C_CYAN }, currency: 'Rp', - format: xf({ f: 0, b: '.' }) + format: xf({ f: 0, b: '.' }), + sysdate: 'dddd, dd mmmm yyyy', + systime: 'hh.mm.ss' }, 3, 3), 'id'); const _it = xm({ @@ -498,10 +578,26 @@ export function initLocales () { celeste: C_CYAN, // mac ciano: C_CYAN // win }, - opcodes: { dy: 'a', dd: 'g', wd: 'o', en: 'x' } + opcodes: { dy: 'a', dd: 'g', wd: 'o', en: 'x' }, + systime: 'hh:mm:ss' }, 3, 3); - addLocale({ group: '.', decimal: ',', ..._it, currency: '€', format: xf({}) }, 'it'); - addLocale({ group: '’', decimal: '.', ..._it, currency: 'CHF', format: xf({ o: 1, d: 1, k: '.', l: '.', f: 2, s: 1 }) }, 'it-CH'); + addLocale({ + group: '.', + decimal: ',', + ..._it, + currency: '€', + format: xf({}), + sysdate: 'dddd d mmmm yyyy' + }, 'it'); + addLocale({ + group: '’', + decimal: '.', + ..._it, + currency: 'CHF', + format: + xf({ o: 1, d: 1, k: '.', l: '.', f: 2, s: 1 }), + sysdate: 'dddd, d mmmm yyyy' + }, 'it-CH'); const _no = { decimal: ',', @@ -523,7 +619,9 @@ export function initLocales () { } as Colors, general: 'Standard', opcodes: { dy: 'å', th: 't' }, - currency: 'kr' + currency: 'kr', + sysdate: 'dddd d. mmmm yyyy', + systime: 'hh:mm:ss' }; addLocale(xm({ ..._no, format: xf({ f: 2, c: 1, k: '.', l: '.', s: 1 }) }, -1, 3), 'nb'); addLocale(xm({ ..._no, format: xf({ f: 2, c: 1, k: '.', l: '.', s: 1 }) }, -1, 3), 'no'); @@ -548,7 +646,9 @@ export function initLocales () { general: 'Standardowy', opcodes: { dy: 'r', th: 'g' }, currency: 'zł', - format: xf({ d: 0, k: '.', l: '.' }) + format: xf({ d: 0, k: '.', l: '.' }), + sysdate: 'dddd, d mmmm yyyy', + systime: 'hh:mm:ss' }, 3, -1), 'pl'); const _pt = { @@ -575,7 +675,9 @@ export function initLocales () { ciano: C_CYAN // pc }, currency: '€', - format: xf({ l: '/' }) + format: xf({ l: '/' }), + sysdate: 'd "de" mmmm "de" yyyy', + systime: 'hh:mm:ss' }, 'pt'); addLocale({ ...xm(_pt, 3, 3), @@ -592,7 +694,9 @@ export function initLocales () { ciano: C_CYAN }, currency: 'R$', - format: xf({ f: 2, l: '/' }) + format: xf({ f: 2, l: '/' }), + sysdate: 'dddd, d "de" mmmm "de" yyyy', + systime: 'hh:mm:ss' }, 'pt-BR'); addLocale({ @@ -620,7 +724,9 @@ export function initLocales () { голубой: C_CYAN }, currency: '₽', - format: xf({ h: 0, k: '.', l: '.' }) + format: xf({ h: 0, k: '.', l: '.' }), + sysdate: 'd mmmm yyyy "г."', + systime: 'h:mm:ss' }, 'ru'); addLocale(xm({ @@ -640,7 +746,9 @@ export function initLocales () { azúrová: C_CYAN }, currency: '€', - format: xf(fp2) + format: xf(fp2), + sysdate: 'dddd d. mmmm yyyy', + systime: 'h:mm:ss' }, 3, 2), 'sk'); const _es = { @@ -662,17 +770,25 @@ export function initLocales () { magenta: C_MAGENTA, cian: C_CYAN, // mac ciano: C_CYAN // pc - } as Colors + } as Colors, + systime: 'h:mm:ss', + sysdate: 'dddd, d "de" mmmm "de" yyyy' }; const _esM3 = _M('ene;feb;mar;abr;may;jun;jul;ago;sep;oct;nov;dic'); const _esM3s = _M('ene;feb;mar;abr;may;jun;jul;ago;sept;oct;nov;dic'); addLocale({ ..._es, ddd: _W('do;lu;ma;mi;ju;vi;sá'), general: 'Estándar', opcodes: { dy: 'a', wd: 'o' }, currency: '€', format: xf({ h: 0, d: 1 }) }, 'es'); - addLocale({ ..._es, mmm: _esM3s, format: xf({ d: 0, f: 2, m: 0 }) }, 'es-AR'); - addLocale({ ..._es, mmm: _esM3s, currency: 'Bs', format: xf({ d: 0, f: 0, m: 0 }) }, 'es-BO'); + addLocale({ ..._es, mmm: _esM3s, format: xf({ d: 0, f: 2, m: 0 }), systime: 'hh:mm:ss' }, 'es-AR'); + addLocale({ ..._es, mmm: _esM3s, currency: 'Bs', format: xf({ d: 0, f: 0, m: 0 }), systime: 'hh:mm:ss' }, 'es-BO'); addLocale({ ..._es, mmm: _esM3s, format: xf({ h: 0, f: 0, s: 1, k: '-' }) }, 'es-CL'); - addLocale({ ..._es, mmm: _esM3, format: xf({ h: 0, d: 0, f: 2 }) }, 'es-CO'); + addLocale({ ..._es, mmm: _esM3, format: xf({ h: 0, d: 0, f: 2 }), systime: 'h:mm:ss AM/PM' }, 'es-CO'); addLocale({ ..._es, mmm: _esM3s, format: xf(fp5) }, 'es-EC'); - addLocale({ ..._es, mmm: _esM3s, currency: '₲', format: xf({ d: 0, f: 2, s: 1, m: 0 }) }, 'es-PY'); + addLocale({ + ..._es, + mmm: _esM3s, + currency: '₲', + format: xf({ d: 0, f: 2, s: 1, m: 0 }), + systime: 'hh:mm:ss' + }, 'es-PY'); addLocale({ ..._es, group: ',', @@ -681,7 +797,8 @@ export function initLocales () { ampm: _B('a.m.;p.m.'), opcodes: { dy: 'a', wd: 'o' }, general: 'Estándar', - format: xf({ f: 0, i: 1 }) + format: xf({ f: 0, i: 1 }), + systime: 'hh:mm:ss AM/PM' }, 'es-MX'); addLocale({ ..._es, @@ -693,7 +810,8 @@ export function initLocales () { ..._es, mmm: _esM3s, currency: 'Bs.S', - format: xf(fp5) + format: xf(fp5), + systime: 'h:mm:ss AM/PM' }, 'es-VE'); addLocale(xm({ @@ -716,7 +834,9 @@ export function initLocales () { cyanblå: C_CYAN }, currency: 'kr', - format: xf({ o: 2, k: '-' }) + format: xf({ o: 2, k: '-' }), + sysdate: '"den" d mmmm yyyy', + systime: 'hh:mm:ss' }, 3, 3), 'sv'); addLocale(xm({ @@ -742,7 +862,9 @@ export function initLocales () { opcodes: { dm: 'a', dd: 'g', th: 's', tm: 'd', ts: 'n' }, general: 'Genel', currency: '₺', - format: xf({ d: 0, f: 0, k: '.', l: '.' }) + format: xf({ d: 0, f: 0, k: '.', l: '.' }), + sysdate: 'd mmmm yyyy dddd', + systime: 'hh:mm:ss' }, 3, -1), 'tr'); addLocale({ @@ -753,7 +875,9 @@ export function initLocales () { dddd: _W('Dydd Sul;Dydd Llun;Dydd Mawrth;Dydd Mercher;Dydd Iau;Dydd Gwener;Dydd Sadwrn'), ddd: _W('Sul;Llun;Maw;Mer;Iau;Gwe;Sad'), currency: '£', - format: xf({ f: 0, p: 0 }) + format: xf({ f: 0, p: 0 }), + sysdate: 'dddd, d mmmm yyyy', + systime: 'hh:mm:ss' }, 'cy'); addLocale({ @@ -764,7 +888,9 @@ export function initLocales () { dddd: _W('bazar;bazar ertəsi;çərşənbə axşamı;çərşənbə;cümə axşamı;cümə;şənbə'), ddd: _W('B;B.E;Ç.A;Ç;C.A;C;Ş'), currency: '₼', - format: xf(fp1) + format: xf(fp1), + sysdate: 'd mmmm yyyy, dddd', + systime: 'hh:mm:ss' }, 'az'); addLocale(xm({ @@ -774,7 +900,9 @@ export function initLocales () { dddd: _W('нядзеля;панядзелак;аўторак;серада;чацвер;пятніца;субота'), ddd: _W('нд;пн;аўт;ср;чц;пт;сб'), currency: 'Br', - format: xf({ y: 1, k: '.', l: '.' }) + format: xf({ y: 1, k: '.', l: '.' }), + sysdate: 'd mmmm yyyy', + systime: 'hh:mm:ss' }, 3, -1), 'be'); addLocale({ @@ -786,7 +914,9 @@ export function initLocales () { ddd: _W('нед;пон;вт;ср;четв;пет;съб'), currency: 'лв.', // bool: _B('ИСТИНА;ЛОЖЬ'), - format: xf(fp2) + format: xf(fp2), + sysdate: 'dd mmmm yyyy "г."', + systime: 'h:mm:ss' }, 'bg'); addLocale({ @@ -800,7 +930,9 @@ export function initLocales () { opcodes: { dy: 'a', wd: 'o' }, ampm: _B('a.\u00a0m.;p.\u00a0m.'), currency: '€', - format: xf({ d: 0, o: 1, h: 0, m: 0 }) + format: xf({ d: 0, o: 1, h: 0, m: 0 }), + sysdate: 'dddd, d mmmm "de" yyyy', + systime: 'h:mm:ss' }, 'ca'); addLocale(xm({ @@ -809,7 +941,9 @@ export function initLocales () { mmmm: _M('Enero;Pebrero;Marso;Abril;Mayo;Hunyo;Hulyo;Agosto;Setyembre;Oktubre;Nobyembre;Disyembre'), dddd: _W('Linggo;Lunes;Martes;Miyerkules;Huwebes;Biyernes;Sabado'), currency: '₱', - format: xf({ h: 0, d: 0, f: 0, m: 0, o: 0 }) + format: xf({ h: 0, d: 0, f: 0, m: 0, o: 0 }), + sysdate: 'dddd, mmmm d, yyyy', + systime: 'h:mm:ss AM/PM' }, 3, 3), 'fil'); addLocale({ @@ -821,7 +955,9 @@ export function initLocales () { dddd: _W('રવિ~;સોમ~;મંગળ~;બુધ~;ગુરુ~;શુક્ર~;શનિ~', 'વાર'), ddd: _W('રવિ;સોમ;મંગળ;બુધ;ગુરુ;શુક્ર;શનિ'), currency: '₹', - format: xf(fp3) + format: xf(fp3), + sysdate: 'dd mmmm yyyy', + systime: 'hh:mm:ss' }, 'gu'); addLocale({ @@ -846,7 +982,9 @@ export function initLocales () { 'תכלת': C_CYAN }, currency: '₪', - format: xf({ f: 2, s: 1 }) + format: xf({ f: 2, s: 1 }), + sysdate: 'dddd dd mmmm yyyy', + systime: 'hh:mm:ss' }, 'he'); addLocale(xm({ @@ -856,7 +994,9 @@ export function initLocales () { mmm: _M('sij;vlj;ožu;tra;svi;lip;srp;kol;ruj;lis;stu;pro'), dddd: _W('nedjelja;ponedjeljak;utorak;srijeda;četvrtak;petak;subota'), currency: '€', - format: xf(fp2) + format: xf(fp2), + sysdate: 'd. mmmm yyyy.', + systime: 'h:mm:ss' }, -1, 3), 'hr'); addLocale({ @@ -866,7 +1006,9 @@ export function initLocales () { dddd: _W('Կիրակի;Երկուշաբթի;Երեքշաբթի;Չորեքշաբթի;Հինգշաբթի;Ուրբաթ;Շաբաթ'), ddd: _W('Կիր;Երկ;Երք;Չրք;Հնգ;Ուր;Շբթ'), currency: '֏', - format: xf(fp1) + format: xf(fp1), + sysdate: 'd mmmm, yyyy', + systime: 'hh:mm:ss' }, 'hy'); addLocale(xm({ @@ -875,7 +1017,9 @@ export function initLocales () { dddd: _W('კვირა;ორშაბათი;სამშაბათი;ოთხშაბათი;ხუთშაბათი;პარასკევი;შაბათი'), ddd: _W('კვ;ორშ;სამშ;ოთხშ;ხუთშ;პარ;შაბ'), currency: '₾', - format: xf(fp1) + format: xf(fp1), + sysdate: 'dddd, dd mmmm, yyyy', + systime: 'hh:mm:ss' }, 3, -1), 'ka'); addLocale(xm({ @@ -887,7 +1031,9 @@ export function initLocales () { opcodes: { dy: 'г', dm: 'м', dd: 'д', th: 'ч', tm: 'м', ts: 'с' }, currency: '₸', general: 'Основной', - format: xf(fp1) + format: xf(fp1), + sysdate: 'yyyy ж. d mmmm, dddd', + systime: 'hh:mm:ss' }, -1, -1), 'kk'); addLocale({ @@ -898,7 +1044,9 @@ export function initLocales () { ddd: _W('ಭಾನು;ಸೋಮ;ಮಂಗಳ;ಬುಧ;ಗುರು;ಶುಕ್ರ;ಶನಿ'), ampm: _B('ಪೂರ್ವಾಹ್ನ;ಅಪರಾಹ್ನ'), currency: '₹', - format: xf(fp3) + format: xf(fp3), + sysdate: 'dd mmmm yyyy', + systime: 'hh:mm:ss' }, 'kn'); addLocale({ @@ -909,7 +1057,9 @@ export function initLocales () { ddd: _W('sk;pr;an;tr;kt;pn;št'), ampm: _B('priešpiet;popiet'), currency: '€', - format: xf({ o: 2, k: '-' }) + format: xf({ o: 2, k: '-' }), + sysdate: 'yyyy "m." mmmm d "d.," dddd', // XXX: illegal format + systime: 'hh:mm:ss' }, 'lt'); addLocale({ @@ -920,7 +1070,9 @@ export function initLocales () { ddd: _W('Svētd;Pirmd;Otrd;Trešd;Ceturtd;Piektd;Sestd'), ampm: _B('priekšp.;pēcp.'), currency: '€', - format: xf(fp1) + format: xf(fp1), + sysdate: 'dddd, yyyy. "gada" d. mmmm', // XXX: ??? + systime: 'hh:mm:ss' }, 'lv'); addLocale({ @@ -931,7 +1083,9 @@ export function initLocales () { dddd: _W('ഞായറാഴ്‌ച;തിങ്കളാഴ്‌ച;ചൊവ്വാഴ്ച;ബുധനാഴ്‌ച;വ്യാഴാഴ്‌ച;വെള്ളിയാഴ്‌ച;ശനിയാഴ്‌ച'), ddd: _W('ഞായർ;തിങ്കൾ;ചൊവ്വ;ബുധൻ;വ്യാഴം;വെള്ളി;ശനി'), currency: '₹', - format: xf({ d: 0, m: 0, h: 0, y: 0, f: 0, o: 1, k: '/', b: ':', s: 0 }) + format: xf({ d: 0, m: 0, h: 0, y: 0, f: 0, o: 1, k: '/', b: ':', s: 0 }), + sysdate: 'yyyy, mmmm d, dddd', + systime: 'h:mm:ss AM/PM' }, 'ml'); addLocale({ @@ -943,7 +1097,9 @@ export function initLocales () { ddd: _W('Ня;Да;Мя;Лха;Пү;Ба;Бя'), ampm: _B('ү.ө.;ү.х.'), currency: '₮', - format: xf({ o: 2, f: 2, k: '.', l: '.' }) + format: xf({ o: 2, f: 2, k: '.', l: '.' }), + sysdate: 'yyyy оны mmmmын d, dddd гараг', // XXX: ??? + systime: 'hh:mm:ss' }, 'mn'); addLocale({ @@ -955,7 +1111,9 @@ export function initLocales () { dddd: _W('रविवार;सोमवार;मंगळवार;बुधवार;गुरुवार;शुक्रवार;शनिवार'), ddd: _W('रवि;सोम;मंगळ;बुध;गुरु;शुक्र;शनि'), currency: '₹', - format: xf(fp4) + format: xf(fp4), + sysdate: 'dd mmmm yyyy', + systime: 'hh:mm:ss' }, 'mr'); addLocale(xm({ @@ -966,7 +1124,9 @@ export function initLocales () { dddd: _W('တနင်္ဂနွေ;တနင်္လာ;အင်္ဂါ;ဗုဒ္ဓဟူး;ကြာသပတေး;သောကြာ;စနေ'), ampm: _B('နံနက်;ညနေ'), currency: 'K', - format: xf({ h: 0, d: 0, m: 0 }) + format: xf({ h: 0, d: 0, m: 0 }), + sysdate: 'yyyy၊ mmmm d၊ dddd', + systime: 'h:mm:ss' }, -1, 0), 'my'); addLocale(xm({ @@ -977,7 +1137,9 @@ export function initLocales () { ddd: _W('ਐਤ;ਸੋਮ;ਮੰਗਲ;ਬੁੱਧ;ਵੀਰ;ਸ਼ੁਕਰ;ਸ਼ਨਿੱਚਰ'), ampm: [ 'ਸਵੇਰ', 'ਸ਼ਾਮ' ], currency: '₹', - format: xf({ d: 1, i: 1, y: 1, f: 2, o: 1, k: '-', b: ':', s: 1 }) + format: xf({ d: 1, i: 1, y: 1, f: 2, o: 1, k: '-', b: ':', s: 1 }), + sysdate: 'dd mmmm yyyy dddd', + systime: 'AM/PM hh:mm:ss' }), 'pa'); addLocale({ @@ -989,7 +1151,9 @@ export function initLocales () { ddd: _W('dum;lun;mar;mie;joi;vin;sâm'), ampm: _B('a.m.;p.m.'), currency: 'lei', - format: xf(fp1) + format: xf(fp1), + sysdate: 'dddd, d mmmm yyyy', + systime: 'hh:mm:ss' }, 'ro'); addLocale(xm({ @@ -999,7 +1163,9 @@ export function initLocales () { dddd: _W('nedelja;ponedeljek;torek;sreda;četrtek;petek;sobota'), ampm: _B('dop.;pop.'), currency: '€', - format: xf({ d: 0, k: '.', l: '.' }) + format: xf({ d: 0, k: '.', l: '.' }), + sysdate: 'dddd, d. mmmm yyyy', + systime: 'hh:mm:ss' }, 3, 3), 'sl'); addLocale(xm({ @@ -1008,7 +1174,9 @@ export function initLocales () { mmmm: _M('januar;februar;mart;april;maj;jun;jul;avgust;septembar;oktobar;novembar;decembar'), dddd: _W('nedelja;ponedeljak;utorak;sreda;četvrtak;petak;subota'), currency: 'RSD', - format: xf({ d: 0, m: 0, k: '.', l: '.' }) + format: xf({ d: 0, m: 0, k: '.', l: '.' }), + sysdate: 'dddd, d. mmmm yyyy.', + systime: 'hh:mm:ss' }, 3, 3), 'sr'); addLocale(xm({ @@ -1018,7 +1186,9 @@ export function initLocales () { mmmm: _M('ஜனவரி;பிப்ரவரி;மார்ச்;ஏப்ரல்;மே;ஜூன்;ஜூலை;ஆகஸ்ட்;செப்டம்பர்;அக்டோபர்;நவம்பர்;டிசம்பர்'), dddd: _W('ஞாயிறு;திங்கள்;செவ்வாய்;புதன்;வியாழன்;வெள்ளி;சனி'), currency: '₹', - format: xf({ d: 1, y: 0, f: 2, o: 1, k: '-', b: ':', s: 1 }) + format: xf({ d: 1, y: 0, f: 2, o: 1, k: '-', b: ':', s: 1 }), + sysdate: 'dd mmmm yyyy', + systime: 'hh:mm:ss' }), 'ta'); addLocale({ @@ -1029,7 +1199,9 @@ export function initLocales () { dddd: _W('ఆదివారం;సోమవారం;మంగళవారం;బుధవారం;గురువారం;శుక్రవారం;శనివారం'), ddd: _W('ఆది;సోమ;మంగళ;బుధ;గురు;శుక్ర;శని'), currency: '₹', - format: xf({ d: 1, h: 0, y: 0, f: 0, o: 1, k: '-', b: ':', s: 0 }) + format: xf({ d: 1, h: 0, y: 0, f: 0, o: 1, k: '-', b: ':', s: 0 }), + sysdate: 'd, mmmm yyyy, dddd', + systime: 'h:mm:ss AM/PM' }, 'te'); addLocale({ @@ -1040,7 +1212,9 @@ export function initLocales () { ddd: _W('Нд;Пн;Вт;Ср;Чт;Пт;Сб'), ampm: _B('дп;пп'), currency: '₴', - format: xf({ h: 0, k: '.', l: '.' }) + format: xf({ h: 0, k: '.', l: '.' }), + sysdate: 'd mmmm yyyy "р."', + systime: 'h:mm:ss' }, 'uk'); addLocale({ @@ -1052,7 +1226,9 @@ export function initLocales () { ddd: _W('CN;T2;T3;T4;T5;T6;T7'), ampm: _B('SA;CH'), currency: '₫', - format: xf({ h: 0, d: 1 }) + format: xf({ h: 0, d: 1 }), + sysdate: 'dd mmmm yyyy', + systime: 'h:mm:ss AM/PM' }, 'vi'); addLocale(xm({ @@ -1074,7 +1250,9 @@ export function initLocales () { سماوي: C_CYAN }, currency: '⃁', - format: xf({ f: 2, i: 1, y: 1, s: 1 }) + format: xf({ f: 2, i: 1, y: 1, s: 1 }), + sysdate: 'dd/mmmm/yyyy', + systime: 'hh:mm:ss AM/PM' }, 0, 0), 'ar'); addLocale({ @@ -1086,7 +1264,9 @@ export function initLocales () { dddd: _W('রবিবার;সোমবার;মঙ্গলবার;বুধবার;বৃহস্পতিবার;শুক্রবার;শনিবার'), ddd: _W('রবি.;সোম.;মঙ্গল.;বুধ.;বৃহস্পতি.;শুক্র.;শনি.'), currency: '₹', - format: xf({ f: 2, y: 1, k: '-', b: '.', s: 1 }) + format: xf({ f: 2, y: 1, k: '-', b: '.', s: 1 }), + sysdate: 'dd mmmm yyyy', + systime: 'hh.mm.ss' }, 'bn'); addLocale({ @@ -1098,6 +1278,8 @@ export function initLocales () { ddd: _W('रवि.;सोम.;मंगल.;बुध.;गुरु.;शुक्र.;शनि.'), ampm: [ 'पूर्वाह्न', 'अपराह्न' ], currency: '₹', - format: xf(fp4) + format: xf(fp4), + sysdate: 'dd mmmm yyyy', + systime: 'hh:mm:ss' }, 'hi'); } diff --git a/lib/parseFormatSection.ts b/lib/parseFormatSection.ts index 739187e..40fe422 100644 --- a/lib/parseFormatSection.ts +++ b/lib/parseFormatSection.ts @@ -1,4 +1,3 @@ -import { resolveLocale } from './locale.ts'; import { u_YEAR, u_MONTH, u_DAY, u_HOUR, u_MIN, u_SEC, u_DSEC, u_CSEC, u_MSEC, EPOCH_1900, EPOCH_1317, @@ -15,6 +14,7 @@ import { } from './constants.ts'; import type { DateRenderToken, Token, RenderToken, SectionType } from './types.ts'; import { createPartition } from './createPartition.ts'; +import { parseLocaleInstr } from './parseLocaleInstr.ts'; function add (s: string | RenderToken, tokens: RenderToken[]): void { // allow adding string tokens without wrapping @@ -334,28 +334,25 @@ export function parseFormatSection (inputTokens: Token[]) { } } - // locale code -- we extend to allow std. "en-US" style codes - // https://stackoverflow.com/questions/54134729/what-does-the-130000-in-excel-locale-code-130000-mean/54540455#54540455 + // locale code else if (type === TOKEN_LOCALE) { - const bits = token.value.split('-'); - const code = bits.length < 2 ? '' : bits.slice(1).join('-'); - - const currency = bits[0]; - if (currency) { - add(currency, outputTokens); + const props = parseLocaleInstr(token.value); + if (props.currency) { + add(props.currency, outputTokens); } - - const l4e = resolveLocale(code); - if (l4e) { part.locale = l4e; } - const wincode = parseInt(code, 16); - if (isFinite(wincode) && (wincode & 0xff0000)) { - const cal = (wincode >> 16) & 0xff; - // only Hijri is supported atm. - if (cal === 6) { - part.date_system = EPOCH_1317; - } + if (props.sysdate) { + part.sysdate = true; + } + if (props.systime) { + part.systime = true; + } + if (props.locale) { + part.locale = props.locale; + } + // only Gergorian and Hijri are supported atm. + if (props.calendar === EPOCH_1900 || props.calendar === EPOCH_1317) { + part.date_system = props.calendar; } - haveLocale = true; // ignore any B2 & B1 tokens } diff --git a/lib/parseLocaleInstr.ts b/lib/parseLocaleInstr.ts new file mode 100644 index 0000000..6bfcec7 --- /dev/null +++ b/lib/parseLocaleInstr.ts @@ -0,0 +1,133 @@ +import { codeToLocale } from './codeToLocale.ts'; +import { resolveLocale } from './locale.ts'; + +export type LocaleInstruction = { + numberStyle?: number; + calendar?: number; + locale?: string; + currency?: string; + sysdate?: boolean; + systime?: boolean; +}; + +/** + * Parse the contents of a locale instruction in a format pattern, such as + * `[$€-407]` or `[$-en-US,6]`. + * + * The instruction can take one of two forms. Each can be prefixed with a + * currency symbol, which is everything before the first `-`: + * + * - **LCID style:** `-xxyyzzzz`, a hexadecimal code where `xx` is the number + * system, `yy` is the calendar, and `zzzz` is the Windows locale ID. Leading + * parts can be omitted, as in `-409`. + * - **BCP 47 style:** `-tag[,xxyy]`, a locale tag such as `en-US`, optionally + * followed by a hexadecimal number system (`xx`) and calendar (`yy`). A + * Japanese `-x-gannen` suffix is accepted, but ignored. + * + * The special system date and time codes (`F800` and `F400`, or `x-sysdate` and + * `x-systime`) return only `{ sysdate: true }` or `{ systime: true }`, and + * discard any currency, number system, or calendar. + * + * Unrecognized instructions return an empty object, because Excel mostly + * ignores them. + * + * @internal + * @param value The instruction text between `[$` and `]`, such as `€-407`. + * @returns The parsed instruction. Properties that are absent or zero are omitted. + */ +export function parseLocaleInstr (value: string): LocaleInstruction { + let cal: number | undefined; + let num = 0; + let locale: string | undefined; + let currency = ''; + + // LCID number style: [$-0409] + // See: https://stackoverflow.com/questions/54134729/what-does-the-130000-in-excel-locale-code-130000-mean/54540455#54540455 + const numStyle = /^([^-]*)-([0-9a-fA-F]{3,8})$/.exec(value); + if (numStyle) { + if (numStyle[1]) { + currency = numStyle[1]; + } + const code = parseInt(numStyle[2], 16); + // code is a hex number that follows the convention xxyyzzzz, where: + // ... xx = number system (unsupported currently) + const c = (code >> 24) & 0xff; + if (c) { num = c; } + // ... yy = calendar format (Gregorian, Hijri, ...) + const d = (code >> 16) & 0xff; + if (d) { cal = d; } + // ... zzzz = LCID (locale code) + const e = code & 0xffff; + if (e === 0xF800) { + return { sysdate: true }; + } + else if (e === 0xF400) { + return { systime: true }; + } + else if (e && codeToLocale[e]) { + locale = codeToLocale[e]; + } + } + else { + const bcpStyle = /^([^-]*)-([a-z\d][a-z\d_.@-]*)?(?:,([a-f\d]{1,4}))?$/i.exec(value); + if (bcpStyle) { + let loc = bcpStyle[2]; + if (/^x-sysdate$/.test(loc)) { + return { sysdate: true }; + } + else if (/^x-systime$/.test(loc)) { + return { systime: true }; + } + else { + if (bcpStyle[1]) { + currency = bcpStyle[1]; + } + if (loc) { + if (/-x-gannen$/i.test(loc)) { + // TODO: https://stackoverflow.com/a/64403179/27388 + // > In addition, a gannen suffix `-x-gannen` is allowed on Japanese locale codes, which + // > replaces a `1` value (first year of emperor reign) for `e` formats with `元`. + // > For example: + // > `5/1/2019` with number format `[$-ja-JP-x-gannen]ggg e` is `令和 元` instead of `令和 1` + // > without the gannen indicator. + loc = loc.slice(0, -9); + } + locale = resolveLocale(loc); + } + if (bcpStyle[3]) { + const code = parseInt(bcpStyle[3], 16); + // code is a hex number that follows the convention xxyy, where: + // ... xx = number system (unsupported currently) + const c = (code >> 8) & 0xff; + if (c) { num = c; } + // ... yy = calendar format (Gregorian, Hijri, ...) + const d = code & 0xff; + if (d) { cal = d; } + } + } + } + else if (!value.includes('-')) { + return { currency: value }; + } + else { + return { currency: value }; + // Illegal tag: Excel seems to mostly ignore these + } + } + + // output + const out: LocaleInstruction = {}; + if (cal) { + out.calendar = cal; + } + if (num) { + out.numberStyle = num; + } + if (locale) { + out.locale = locale; + } + if (currency) { + out.currency = currency; + } + return out; +} diff --git a/lib/prepareFormatterData.ts b/lib/prepareFormatterData.ts new file mode 100644 index 0000000..618f424 --- /dev/null +++ b/lib/prepareFormatterData.ts @@ -0,0 +1,48 @@ +import { TOKEN_ERROR } from './constants.ts'; +import { createPartition } from './createPartition.ts'; +import { parsePattern } from './parsePattern.ts'; +import type { FormatDateInfo, FormatInfo, PatternParseData } from './types.ts'; + +export type CacheData = PatternParseData & { dateInfo?: FormatDateInfo, info?: FormatInfo }; + +const _parseDataCache = new Map(); + +/** + * Parse a format pattern, caching the result so each pattern is only parsed once. + * + * If the pattern is invalid, this either throws or returns error partitions + * that format every value as an error. Error results are not cached. + * + * @internal + * @param pattern A format pattern in the ECMA-376 number format. An empty pattern is treated as `General`. + * @param [shouldThrow=false] Throw an error if the pattern is invalid. + * @returns The parsed pattern data. + */ +export function prepareFormatterData (pattern: string, shouldThrow = false): CacheData { + if (!pattern) { pattern = 'General'; } + + let parseData = _parseDataCache.get(pattern); + if (!parseData) { + try { + parseData = parsePattern(pattern); + _parseDataCache.set(pattern, parseData); + } + catch (err) { + // if the options say to throw errors, then do so + if (shouldThrow) { + throw err; + } + // else we set the parsedata to error + const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : 'Unknown error'; + const errPart = createPartition([ { type: TOKEN_ERROR } ]); + errPart.error = true; + parseData = { + pattern: pattern, + partitions: [ errPart, errPart, errPart, errPart ], + error: message, + locale: undefined + }; + } + } + return parseData; +} diff --git a/lib/types.ts b/lib/types.ts index c878bd6..0479bac 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -167,7 +167,9 @@ export type Partition = { sec_decimals: number, text: boolean, tokensUsed: number, - tokens: RenderToken[] + tokens: RenderToken[], + sysdate: boolean, + systime: boolean, }; export type PatternParseData = { diff --git a/test/parseLocaleInstr.spec.ts b/test/parseLocaleInstr.spec.ts new file mode 100644 index 0000000..a9c120f --- /dev/null +++ b/test/parseLocaleInstr.spec.ts @@ -0,0 +1,249 @@ +import { describe, expect, test } from 'vitest'; +import { parseLocaleInstr } from '../lib/parseLocaleInstr.ts'; + +describe('parseLocaleInstr', () => { + describe('LCID style', () => { + test('[$INR]', () => { + expect(parseLocaleInstr('INR')).toEqual({ + currency: 'INR' + }); + }); + }); + + describe('LCID style', () => { + test('[$-409]', () => { + expect(parseLocaleInstr('-409')).toEqual({ + locale: 'en-US' + }); + }); + test('[$-0409]', () => { + expect(parseLocaleInstr('-0409')).toEqual({ + locale: 'en-US' + }); + }); + test('[$$-409]', () => { + expect(parseLocaleInstr('$-409')).toEqual({ + locale: 'en-US', + currency: '$' + }); + }); + test('[$USD-409]', () => { + expect(parseLocaleInstr('USD-409')).toEqual({ + locale: 'en-US', + currency: 'USD' + }); + }); + test('[$-060409]', () => { + expect(parseLocaleInstr('-060409')).toEqual({ + calendar: 6, + locale: 'en-US' + }); + }); + test('[$-010409]', () => { + expect(parseLocaleInstr('-010409')).toEqual({ + calendar: 1, + locale: 'en-US' + }); + }); + + test('[$€-407]', () => { + expect(parseLocaleInstr('€-407')).toEqual({ + locale: 'de-DE', + currency: '€' + }); + }); + + test('[$-0809]', () => { + expect(parseLocaleInstr('-0809')).toEqual({ + locale: 'en-GB' + }); + }); + test('[$-00080409]', () => { + expect(parseLocaleInstr('-00080409')).toEqual({ + calendar: 8, + locale: 'en-US' + }); + }); + + test('[$-1E020404]', () => { + expect(parseLocaleInstr('-1E020404')).toEqual({ + calendar: 2, + locale: 'zh-TW', + numberStyle: 30 + }); + }); + test('[$-00130000]', () => { + expect(parseLocaleInstr('-00130000')).toEqual({ + calendar: 19 + }); + }); + test('[$-0200040F]', () => { + expect(parseLocaleInstr('-0200040F')).toEqual({ + locale: 'is', + numberStyle: 2 + }); + }); + }); + + describe('BCP 47 style', () => { + test('[$-en-US]', () => { + expect(parseLocaleInstr('-en-US')).toEqual({ + locale: 'en-US' + }); + }); + test('[$-en-US,6]', () => { + expect(parseLocaleInstr('-en-US,6')).toEqual({ + calendar: 6, + locale: 'en-US' + }); + }); + test('[$€-de-DE]', () => { + expect(parseLocaleInstr('€-de-DE')).toEqual({ + currency: '€', + locale: 'de-DE' + }); + }); + test('[$€-en-US,6]', () => { + expect(parseLocaleInstr('€-en-US,6')).toEqual({ + calendar: 6, + currency: '€', + locale: 'en-US' + }); + }); + test('[$€-en-US,6]', () => { + expect(parseLocaleInstr('€-en-US,1E02')).toEqual({ + calendar: 2, + numberStyle: 30, + currency: '€', + locale: 'en-US' + }); + }); + test('[$-ja-JP]', () => { + expect(parseLocaleInstr('-ja-JP')).toEqual({ + locale: 'ja-JP' + }); + }); + test('[$-ja-JP-x-gannen]', () => { + expect(parseLocaleInstr('-ja-JP-x-gannen')).toEqual({ + locale: 'ja-JP' + }); + }); + test('[$-,1]', () => { + expect(parseLocaleInstr('-,1')).toEqual({ + calendar: 1 + }); + }); + test('[$-,6]', () => { + expect(parseLocaleInstr('-,6')).toEqual({ + calendar: 6 + }); + }); + test('[$-,6]', () => { + expect(parseLocaleInstr('-,6')).toEqual({ + calendar: 6 + }); + }); + test('[$USD-,6]', () => { + expect(parseLocaleInstr('USD-,6')).toEqual({ + currency: 'USD', + calendar: 6 + }); + }); + }); + + describe('sysdate / systime', () => { + test('[$-x-sysdate]', () => { + expect(parseLocaleInstr('-x-sysdate')).toEqual({ + sysdate: true + }); + }); + test('[$-x-sysdate,BE3C]', () => { + expect(parseLocaleInstr('-x-sysdate,BE3C')).toEqual({ + sysdate: true + }); + }); + test('[$€-x-sysdate,BE3C]', () => { + expect(parseLocaleInstr('€-x-sysdate,BE3C')).toEqual({ + sysdate: true + }); + }); + test('[$€-x-sysdate]', () => { + expect(parseLocaleInstr('€-x-sysdate')).toEqual({ + sysdate: true + }); + }); + + test('[$-F800]', () => { + expect(parseLocaleInstr('-F800')).toEqual({ + sysdate: true + }); + }); + test('[$-02F800]', () => { + expect(parseLocaleInstr('-02F800')).toEqual({ + sysdate: true + }); + }); + test('[$-1E02F800]', () => { + expect(parseLocaleInstr('-1E02F800')).toEqual({ + sysdate: true + }); + }); + test('[$€-1E02F800]', () => { + expect(parseLocaleInstr('€-1E02F800')).toEqual({ + sysdate: true + }); + }); + test('[$€-F800]', () => { + expect(parseLocaleInstr('€-F800')).toEqual({ + sysdate: true + }); + }); + + test('[$-x-systime]', () => { + expect(parseLocaleInstr('-x-systime')).toEqual({ + systime: true + }); + }); + test('[$-x-systime,BE3C]', () => { + expect(parseLocaleInstr('-x-systime,BE3C')).toEqual({ + systime: true + }); + }); + test('[$€-x-systime,BE3C]', () => { + expect(parseLocaleInstr('€-x-systime,BE3C')).toEqual({ + systime: true + }); + }); + test('[$€-x-systime]', () => { + expect(parseLocaleInstr('€-x-systime')).toEqual({ + systime: true + }); + }); + + test('[$-F400]', () => { + expect(parseLocaleInstr('-F400')).toEqual({ + systime: true + }); + }); + test('[$-02F400]', () => { + expect(parseLocaleInstr('-02F400')).toEqual({ + systime: true + }); + }); + test('[$-1E02F400]', () => { + expect(parseLocaleInstr('-1E02F400')).toEqual({ + systime: true + }); + }); + test('[$€-1E02F400]', () => { + expect(parseLocaleInstr('€-1E02F400')).toEqual({ + systime: true + }); + }); + test('[$€-F400]', () => { + expect(parseLocaleInstr('€-F400')).toEqual({ + systime: true + }); + }); + }); +}); diff --git a/test/sysdate.spec.ts b/test/sysdate.spec.ts new file mode 100644 index 0000000..86ee806 --- /dev/null +++ b/test/sysdate.spec.ts @@ -0,0 +1,451 @@ +import { describe, expect, test } from 'vitest'; +import { format } from '../lib/index.ts'; + +const MAGICDATE = 3290.1278435; + +describe('-x-sysdate/-x-systime', () => { + test('ar-SA', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ar-SA' })).toBe('02/يناير/1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ar-SA' })).toBe('03:04:06 ص'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ar-SA' })).toBe('02/يناير/1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ar-SA' })).toBe('03:04:06 ص'); + }); + test('az-AZ', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'az-AZ' })).toBe('2 yanvar 1909, şənbə'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'az-AZ' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'az-AZ' })).toBe('2 yanvar 1909, şənbə'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'az-AZ' })).toBe('03:04:06'); + }); + test('be-BY', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'be-BY' })).toBe('2 студзень 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'be-BY' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'be-BY' })).toBe('2 студзень 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'be-BY' })).toBe('03:04:06'); + }); + test('bg-BG', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'bg-BG' })).toBe('02 януари 1909 г.'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'bg-BG' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'bg-BG' })).toBe('02 януари 1909 г.'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'bg-BG' })).toBe('3:04:06'); + }); + test('bn-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'bn-IN' })).toBe('02 জানুয়ারী 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'bn-IN' })).toBe('03.04.06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'bn-IN' })).toBe('02 জানুয়ারী 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'bn-IN' })).toBe('03.04.06'); + }); + test('ca-ES', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ca-ES' })).toBe('dissabte, 2 gener de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ca-ES' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ca-ES' })).toBe('dissabte, 2 gener de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ca-ES' })).toBe('3:04:06'); + }); + test('cs-CZ', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'cs-CZ' })).toBe('sobota 2. leden 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'cs-CZ' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'cs-CZ' })).toBe('sobota 2. leden 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'cs-CZ' })).toBe('3:04:06'); + }); + test('cy-GB', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'cy-GB' })).toBe('Dydd Sadwrn, 2 Ionawr 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'cy-GB' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'cy-GB' })).toBe('Dydd Sadwrn, 2 Ionawr 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'cy-GB' })).toBe('03:04:06'); + }); + test.only('da-DK', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'da-DK' })).toBe('2. januar 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'da-DK' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'da-DK' })).toBe('2. januar 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'da-DK' })).toBe('03:04:06'); + }); + test('de-CH', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'de-CH' })).toBe('Samstag, 2. Januar 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'de-CH' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'de-CH' })).toBe('Samstag, 2. Januar 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'de-CH' })).toBe('03:04:06'); + }); + test('de-DE', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'de-DE' })).toBe('Samstag, 2. Januar 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'de-DE' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'de-DE' })).toBe('Samstag, 2. Januar 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'de-DE' })).toBe('03:04:06'); + }); + test('el-GR', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'el-GR' })).toBe('Σάββατο, 2 Ιανουαρίου 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'el-GR' })).toBe('3:04:06 πμ'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'el-GR' })).toBe('Σάββατο, 2 Ιανουαρίου 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'el-GR' })).toBe('3:04:06 πμ'); + }); + test('en-AU', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'en-AU' })).toBe('Saturday, 2 January 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'en-AU' })).toBe('3:04:06 AM'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'en-AU' })).toBe('Saturday, 2 January 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'en-AU' })).toBe('3:04:06 AM'); + }); + test('en-CA', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'en-CA' })).toBe('January 2, 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'en-CA' })).toBe('3:04:06 AM'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'en-CA' })).toBe('January 2, 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'en-CA' })).toBe('3:04:06 AM'); + }); + test('en-GB', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'en-GB' })).toBe('02 January 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'en-GB' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'en-GB' })).toBe('02 January 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'en-GB' })).toBe('03:04:06'); + }); + test('en-IE', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'en-IE' })).toBe('Saturday 2 January 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'en-IE' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'en-IE' })).toBe('Saturday 2 January 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'en-IE' })).toBe('03:04:06'); + }); + test('en-US', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'en-US' })).toBe('Saturday, January 2, 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'en-US' })).toBe('3:04:06 AM'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'en-US' })).toBe('Saturday, January 2, 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'en-US' })).toBe('3:04:06 AM'); + }); + test('es-AR', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-AR' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-AR' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-AR' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-AR' })).toBe('03:04:06'); + }); + test('es-BO', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-BO' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-BO' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-BO' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-BO' })).toBe('03:04:06'); + }); + test('es-CL', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-CL' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-CL' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-CL' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-CL' })).toBe('3:04:06'); + }); + test('es-CO', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-CO' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-CO' })).toBe('3:04:06 a. m.'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-CO' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-CO' })).toBe('3:04:06 a. m.'); + }); + test('es-EC', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-EC' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-EC' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-EC' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-EC' })).toBe('3:04:06'); + }); + test('es-ES', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-ES' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-ES' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-ES' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-ES' })).toBe('3:04:06'); + }); + test('es-MX', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-MX' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-MX' })).toBe('03:04:06 a. m.'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-MX' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-MX' })).toBe('03:04:06 a. m.'); + }); + test('es-PY', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-PY' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-PY' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-PY' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-PY' })).toBe('03:04:06'); + }); + test('es-UY', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-UY' })).toBe('sábado, 2 de Enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-UY' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-UY' })).toBe('sábado, 2 de Enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-UY' })).toBe('3:04:06'); + }); + test('es-VE', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'es-VE' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'es-VE' })).toBe('3:04:06 a. m.'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'es-VE' })).toBe('sábado, 2 de enero de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'es-VE' })).toBe('3:04:06 a. m.'); + }); + test('fi-FI', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'fi-FI' })).toBe('lauantai 2. tammikuu 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'fi-FI' })).toBe('3.04.06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'fi-FI' })).toBe('lauantai 2. tammikuu 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'fi-FI' })).toBe('3.04.06'); + }); + test('fil-PH', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'fil-PH' })).toBe('Sabado, Enero 2, 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'fil-PH' })).toBe('3:04:06 AM'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'fil-PH' })).toBe('Sabado, Enero 2, 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'fil-PH' })).toBe('3:04:06 AM'); + }); + test('fr-CA', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'fr-CA' })).toBe('2 janvier 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'fr-CA' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'fr-CA' })).toBe('2 janvier 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'fr-CA' })).toBe('03:04:06'); + }); + test('fr-CH', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'fr-CH' })).toBe('samedi, 2 janvier 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'fr-CH' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'fr-CH' })).toBe('samedi, 2 janvier 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'fr-CH' })).toBe('03:04:06'); + }); + test('fr-FR', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'fr-FR' })).toBe('samedi 2 janvier 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'fr-FR' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'fr-FR' })).toBe('samedi 2 janvier 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'fr-FR' })).toBe('03:04:06'); + }); + test('gu-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'gu-IN' })).toBe('02 જાન્યુઆરી 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'gu-IN' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'gu-IN' })).toBe('02 જાન્યુઆરી 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'gu-IN' })).toBe('03:04:06'); + }); + test('he-IL', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'he-IL' })).toBe('שבת 02 ינואר 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'he-IL' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'he-IL' })).toBe('שבת 02 ינואר 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'he-IL' })).toBe('03:04:06'); + }); + test('hi-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'hi-IN' })).toBe('02 जनवरी 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'hi-IN' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'hi-IN' })).toBe('02 जनवरी 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'hi-IN' })).toBe('03:04:06'); + }); + test('hr-HR', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'hr-HR' })).toBe('2. siječanj 1909.'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'hr-HR' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'hr-HR' })).toBe('2. siječanj 1909.'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'hr-HR' })).toBe('3:04:06'); + }); + test('hu-HU', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'hu-HU' })).toBe('1909. január 2., szombat'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'hu-HU' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'hu-HU' })).toBe('1909. január 2., szombat'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'hu-HU' })).toBe('3:04:06'); + }); + test('hy-AM', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'hy-AM' })).toBe('2 Հունվար, 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'hy-AM' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'hy-AM' })).toBe('2 Հունվար, 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'hy-AM' })).toBe('03:04:06'); + }); + test('id-ID', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'id-ID' })).toBe('Sabtu, 02 Januari 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'id-ID' })).toBe('03.04.06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'id-ID' })).toBe('Sabtu, 02 Januari 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'id-ID' })).toBe('03.04.06'); + }); + test('is-IS', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'is-IS' })).toBe('laugardagur, 2. janúar 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'is-IS' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'is-IS' })).toBe('laugardagur, 2. janúar 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'is-IS' })).toBe('03:04:06'); + }); + test('it-CH', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'it-CH' })).toBe('sabato, 2 gennaio 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'it-CH' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'it-CH' })).toBe('sabato, 2 gennaio 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'it-CH' })).toBe('03:04:06'); + }); + test('it-IT', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'it-IT' })).toBe('sabato 2 gennaio 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'it-IT' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'it-IT' })).toBe('sabato 2 gennaio 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'it-IT' })).toBe('03:04:06'); + }); + test('ja-JP', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ja-JP' })).toBe('1909年1月2日'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ja-JP' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ja-JP' })).toBe('1909年1月2日'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ja-JP' })).toBe('3:04:06'); + }); + test('ka-GE', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ka-GE' })).toBe('შაბათი, 02 იანვარი, 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ka-GE' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ka-GE' })).toBe('შაბათი, 02 იანვარი, 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ka-GE' })).toBe('03:04:06'); + }); + test('kk-KZ', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'kk-KZ' })).toBe('1909 ж. 2 Қаңтар, сенбі'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'kk-KZ' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'kk-KZ' })).toBe('1909 ж. 2 Қаңтар, сенбі'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'kk-KZ' })).toBe('03:04:06'); + }); + test('kn-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'kn-IN' })).toBe('02 ಜನವರಿ 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'kn-IN' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'kn-IN' })).toBe('02 ಜನವರಿ 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'kn-IN' })).toBe('03:04:06'); + }); + test('ko-KR', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ko-KR' })).toBe('1909년 1월 2일 토요일'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ko-KR' })).toBe('오전 3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ko-KR' })).toBe('1909년 1월 2일 토요일'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ko-KR' })).toBe('오전 3:04:06'); + }); + test('lt-LT', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'lt-LT' })).toBe('1909 m. sausis 2 d., šeštadienis'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'lt-LT' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'lt-LT' })).toBe('1909 m. sausis 2 d., šeštadienis'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'lt-LT' })).toBe('03:04:06'); + }); + test('lv-LV', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'lv-LV' })).toBe('sestdiena, 1909. gada 2. janvāris'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'lv-LV' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'lv-LV' })).toBe('sestdiena, 1909. gada 2. janvāris'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'lv-LV' })).toBe('03:04:06'); + }); + test('ml-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ml-IN' })).toBe('1909, ജനുവരി 2, ശനിയാഴ്‌ച'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ml-IN' })).toBe('3:04:06 AM'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ml-IN' })).toBe('1909, ജനുവരി 2, ശനിയാഴ്‌ച'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ml-IN' })).toBe('3:04:06 AM'); + }); + test('mn-MN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'mn-MN' })).toBe('1909 оны Нэгдүгээр сарын 2, бямба гараг'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'mn-MN' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'mn-MN' })).toBe('1909 оны Нэгдүгээр сарын 2, бямба гараг'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'mn-MN' })).toBe('03:04:06'); + }); + test('mr-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'mr-IN' })).toBe('02 जानेवारी 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'mr-IN' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'mr-IN' })).toBe('02 जानेवारी 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'mr-IN' })).toBe('03:04:06'); + }); + test('my-MM', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'my-MM' })).toBe('1909၊ ဇန်နဝါရီ 2၊ စနေ'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'my-MM' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'my-MM' })).toBe('1909၊ ဇန်နဝါရီ 2၊ စနေ'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'my-MM' })).toBe('3:04:06'); + }); + test('nb-NO', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'nb-NO' })).toBe('lørdag 2. januar 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'nb-NO' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'nb-NO' })).toBe('lørdag 2. januar 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'nb-NO' })).toBe('03:04:06'); + }); + test('nl-NL', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'nl-NL' })).toBe('zaterdag 2 januari 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'nl-NL' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'nl-NL' })).toBe('zaterdag 2 januari 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'nl-NL' })).toBe('03:04:06'); + }); + test('pa-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'pa-IN' })).toBe('02 ਜਨਵਰੀ 1909 ਸ਼ਨਿੱਚਰਵਾਰ'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'pa-IN' })).toBe('ਸਵੇਰ 03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'pa-IN' })).toBe('02 ਜਨਵਰੀ 1909 ਸ਼ਨਿੱਚਰਵਾਰ'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'pa-IN' })).toBe('ਸਵੇਰ 03:04:06'); + }); + test('pl-PL', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'pl-PL' })).toBe('sobota, 2 styczeń 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'pl-PL' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'pl-PL' })).toBe('sobota, 2 styczeń 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'pl-PL' })).toBe('03:04:06'); + }); + test('pt-BR', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'pt-BR' })).toBe('sábado, 2 de janeiro de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'pt-BR' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'pt-BR' })).toBe('sábado, 2 de janeiro de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'pt-BR' })).toBe('03:04:06'); + }); + test('pt-PT', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'pt-PT' })).toBe('2 de janeiro de 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'pt-PT' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'pt-PT' })).toBe('2 de janeiro de 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'pt-PT' })).toBe('03:04:06'); + }); + test('ro-RO', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ro-RO' })).toBe('sâmbătă, 2 ianuarie 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ro-RO' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ro-RO' })).toBe('sâmbătă, 2 ianuarie 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ro-RO' })).toBe('03:04:06'); + }); + test('ru-RU', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ru-RU' })).toBe('2 Январь 1909 г.'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ru-RU' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ru-RU' })).toBe('2 Январь 1909 г.'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ru-RU' })).toBe('3:04:06'); + }); + test('sk-SK', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'sk-SK' })).toBe('sobota 2. január 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'sk-SK' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'sk-SK' })).toBe('sobota 2. január 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'sk-SK' })).toBe('3:04:06'); + }); + test('sl-SI', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'sl-SI' })).toBe('sobota, 2. januar 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'sl-SI' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'sl-SI' })).toBe('sobota, 2. januar 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'sl-SI' })).toBe('03:04:06'); + }); + test('sr-RS', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'sr-RS' })).toBe('subota, 2. januar 1909.'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'sr-RS' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'sr-RS' })).toBe('subota, 2. januar 1909.'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'sr-RS' })).toBe('03:04:06'); + }); + test('sv-SE', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'sv-SE' })).toBe('den 2 januari 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'sv-SE' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'sv-SE' })).toBe('den 2 januari 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'sv-SE' })).toBe('03:04:06'); + }); + test('ta-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'ta-IN' })).toBe('02 ஜனவரி 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'ta-IN' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'ta-IN' })).toBe('02 ஜனவரி 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'ta-IN' })).toBe('03:04:06'); + }); + test('te-IN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'te-IN' })).toBe('2, జనవరి 1909, శనివారం'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'te-IN' })).toBe('3:04:06 AM'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'te-IN' })).toBe('2, జనవరి 1909, శనివారం'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'te-IN' })).toBe('3:04:06 AM'); + }); + test('th-TH', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'th-TH' })).toBe('2 มกราคม 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'th-TH' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'th-TH' })).toBe('2 มกราคม 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'th-TH' })).toBe('3:04:06'); + }); + test('tr-TR', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'tr-TR' })).toBe('2 Ocak 1909 Cumartesi'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'tr-TR' })).toBe('03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'tr-TR' })).toBe('2 Ocak 1909 Cumartesi'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'tr-TR' })).toBe('03:04:06'); + }); + test('uk-UA', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'uk-UA' })).toBe('2 січень 1909 р.'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'uk-UA' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'uk-UA' })).toBe('2 січень 1909 р.'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'uk-UA' })).toBe('3:04:06'); + }); + test('vi-VN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'vi-VN' })).toBe('02 Tháng Giêng 1909'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'vi-VN' })).toBe('3:04:06 SA'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'vi-VN' })).toBe('02 Tháng Giêng 1909'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'vi-VN' })).toBe('3:04:06 SA'); + }); + test('zh-CN', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'zh-CN' })).toBe('1909年1月2日'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'zh-CN' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'zh-CN' })).toBe('1909年1月2日'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'zh-CN' })).toBe('3:04:06'); + }); + test('zh-HK', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'zh-HK' })).toBe('1909年1月2日'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'zh-HK' })).toBe('3:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'zh-HK' })).toBe('1909年1月2日'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'zh-HK' })).toBe('3:04:06'); + }); + test('zh-TW', () => { + expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'zh-TW' })).toBe('1909年1月2日'); + expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'zh-TW' })).toBe('上午 03:04:06'); + expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'zh-TW' })).toBe('1909年1月2日'); + expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'zh-TW' })).toBe('上午 03:04:06'); + }); +}); From c7367b5189504e9ccb7d0ae17125445a08a4398b Mon Sep 17 00:00:00 2001 From: Borgar Date: Mon, 5 Oct 2026 16:14:45 +0000 Subject: [PATCH 2/3] Update some locales and remove .only from tests --- lib/locales.ts | 21 ++++++++++++++++----- test/sysdate.spec.ts | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/locales.ts b/lib/locales.ts index 70076fd..f158833 100644 --- a/lib/locales.ts +++ b/lib/locales.ts @@ -434,7 +434,8 @@ export function initLocales () { }, 'fr'); addLocale({ ..._fr, - ampm: [ 'a.m.', 'p.m.' ], + // ampm: [ 'a.m.', 'p.m.' ], + ampm: _B('AM;PM'), format: xf({ p: 1, o: 2, d: 1, k: '-', l: '-', s: 1 }), sysdate: 'd mmmm yyyy' }, 'fr-CA'); @@ -540,7 +541,7 @@ export function initLocales () { addLocale(xm({ group: '.', decimal: ',', - ampm: _B('.AM;.PM'), + ampm: _B('AM;PM'), mmmm: _M('Januari;Februari;Maret;April;Mei;Juni;Juli;Agustus;September;Oktober;November;Desember'), dddd: _W('Minggu;Senin;Selasa;Rabu;Kamis;Jumat;Sabtu'), ddd: _W('Mgg;Sen;Sel;Rab;Kam;Jum;Sab'), @@ -776,7 +777,15 @@ export function initLocales () { }; const _esM3 = _M('ene;feb;mar;abr;may;jun;jul;ago;sep;oct;nov;dic'); const _esM3s = _M('ene;feb;mar;abr;may;jun;jul;ago;sept;oct;nov;dic'); - addLocale({ ..._es, ddd: _W('do;lu;ma;mi;ju;vi;sá'), general: 'Estándar', opcodes: { dy: 'a', wd: 'o' }, currency: '€', format: xf({ h: 0, d: 1 }) }, 'es'); + addLocale({ + ..._es, + ampm: _B('AM;PM'), + ddd: _W('do;lu;ma;mi;ju;vi;sá'), + general: 'Estándar', + opcodes: { dy: 'a', wd: 'o' }, + currency: '€', + format: xf({ h: 0, d: 1 }) + }, 'es'); addLocale({ ..._es, mmm: _esM3s, format: xf({ d: 0, f: 2, m: 0 }), systime: 'hh:mm:ss' }, 'es-AR'); addLocale({ ..._es, mmm: _esM3s, currency: 'Bs', format: xf({ d: 0, f: 0, m: 0 }), systime: 'hh:mm:ss' }, 'es-BO'); addLocale({ ..._es, mmm: _esM3s, format: xf({ h: 0, f: 0, s: 1, k: '-' }) }, 'es-CL'); @@ -794,7 +803,7 @@ export function initLocales () { group: ',', decimal: '.', mmm: _esM3, - ampm: _B('a.m.;p.m.'), + ampm: _B('a. m.;p. m.'), opcodes: { dy: 'a', wd: 'o' }, general: 'Estándar', format: xf({ f: 0, i: 1 }), @@ -869,7 +878,8 @@ export function initLocales () { addLocale({ group: ',', - ampm: _B('yb;yh'), + // ampm: _B('yb;yh'), + ampm: _B('AM;PM'), mmmm: _M('Ionawr;Chwefror;Mawrth;Ebrill;Mai;Mehefin;Gorffennaf;Awst;Medi;Hydref;Tachwedd;Rhagfyr'), mmm: _M('Ion;Chwef;Maw;Ebr;Mai;Meh;Gorff;Awst;Medi;Hyd;Tach;Rhag'), dddd: _W('Dydd Sul;Dydd Llun;Dydd Mawrth;Dydd Mercher;Dydd Iau;Dydd Gwener;Dydd Sadwrn'), @@ -1235,6 +1245,7 @@ export function initLocales () { group: '٬', decimal: '٫', ampm: _B('ص;م'), + percent: '٪', mmmm: _M('يناير;فبراير;مارس;أبريل;مايو;يونيو;يوليو;أغسطس;سبتمبر;أكتوبر;نوفمبر;ديسمبر'), dddd: _W('الأحد;الإثنين;الثلاثاء;الأربعاء;الخميس;الجمعة;السبت'), mmmm6: _M('رمضان;شوال;ذو القعدة;ذو الحجة;محرم;ربيع الأول;ربيع الآخرة;جمادى الأولى;جمادى الآخرة;رجب;شعبان;رمضان'), diff --git a/test/sysdate.spec.ts b/test/sysdate.spec.ts index 86ee806..6a0113e 100644 --- a/test/sysdate.spec.ts +++ b/test/sysdate.spec.ts @@ -52,7 +52,7 @@ describe('-x-sysdate/-x-systime', () => { expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'cy-GB' })).toBe('Dydd Sadwrn, 2 Ionawr 1909'); expect(format('[$-x-systime]hh:mm', MAGICDATE, { locale: 'cy-GB' })).toBe('03:04:06'); }); - test.only('da-DK', () => { + test('da-DK', () => { expect(format('[$-F800]yyyy-mm-dd', MAGICDATE, { locale: 'da-DK' })).toBe('2. januar 1909'); expect(format('[$-F400]hh:mm', MAGICDATE, { locale: 'da-DK' })).toBe('03:04:06'); expect(format('[$-x-sysdate]yyyy-mm-dd', MAGICDATE, { locale: 'da-DK' })).toBe('2. januar 1909'); From fe0174e1cc56878e6625ed8f533375a6e15749cb Mon Sep 17 00:00:00 2001 From: Borgar Date: Mon, 5 Oct 2026 16:28:21 +0000 Subject: [PATCH 3/3] Add missing props --- lib/createPartition.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/createPartition.ts b/lib/createPartition.ts index 3e0f75f..f5baeaf 100644 --- a/lib/createPartition.ts +++ b/lib/createPartition.ts @@ -37,6 +37,8 @@ export function createPartition (tokens?: RenderToken[]): Partition { tokens: tokens ?? [], den_p: '', int_p: '', - denominator: 0 + denominator: 0, + sysdate: false, + systime: false }; }