( locale: string )
| 165 | const tzToMetaZoneMap = extractTimezoneToMetazoneMap() |
| 166 | |
| 167 | async function loadDatesFields( |
| 168 | locale: string |
| 169 | ): Promise<RawDateTimeLocaleInternalData> { |
| 170 | const [caGregorianImport, tznImport, numbersImport] = await Promise.all([ |
| 171 | import(`cldr-dates-full/main/${locale}/ca-gregorian.json`, { |
| 172 | with: {type: 'json'}, |
| 173 | }) as Promise<{default: typeof DateFields}>, |
| 174 | import(`cldr-dates-full/main/${locale}/timeZoneNames.json`, { |
| 175 | with: {type: 'json'}, |
| 176 | }) as Promise<{default: typeof TimeZoneNames}>, |
| 177 | import(`cldr-numbers-full/main/${locale}/numbers.json`, { |
| 178 | with: {type: 'json'}, |
| 179 | }).catch(_ => undefined) as Promise< |
| 180 | {default: typeof NumberFields} | undefined |
| 181 | >, |
| 182 | ]) |
| 183 | const gregorian = |
| 184 | caGregorianImport.default.main[locale as 'en'].dates.calendars.gregorian |
| 185 | const timeZoneNames = |
| 186 | tznImport.default.main[locale as 'en'].dates.timeZoneNames |
| 187 | const numbers = numbersImport?.default.main[locale as 'en'].numbers |
| 188 | const nu = numbers |
| 189 | ? numbers.defaultNumberingSystem === 'latn' |
| 190 | ? ['latn'] |
| 191 | : [numbers.defaultNumberingSystem, 'latn'] |
| 192 | : [] |
| 193 | |
| 194 | let hc: string[] = [] |
| 195 | let region: string | undefined |
| 196 | try { |
| 197 | if (locale !== 'root') { |
| 198 | region = new IntlLocale(locale).maximize().region |
| 199 | } |
| 200 | // Reduce the date fields data down to allowlist of fields needed in the |
| 201 | // FormatJS libs. |
| 202 | hc = ( |
| 203 | processedTimeData[locale] || |
| 204 | processedTimeData[region || ''] || |
| 205 | processedTimeData[`${locale}-001`] || |
| 206 | processedTimeData['001'] |
| 207 | ).map(resolveDateTimeSymbolTable) |
| 208 | // Ensure all locales support at least one 24-hour and one 12-hour format |
| 209 | // This allows users to explicitly override via hourCycle option per ECMA-402 spec |
| 210 | // See: https://github.com/formatjs/formatjs/issues/6020 |
| 211 | if (!hc.includes('h23') && !hc.includes('h24')) { |
| 212 | hc.push('h23') |
| 213 | } |
| 214 | if (!hc.includes('h12') && !hc.includes('h11')) { |
| 215 | hc.push('h12') |
| 216 | } |
| 217 | } catch (e) { |
| 218 | console.error(`Issue extracting hourCycle for ${locale}`) |
| 219 | throw e |
| 220 | } |
| 221 | let timeZoneName: RawDateTimeLocaleInternalData['timeZoneName'] = {} |
| 222 | try { |
| 223 | timeZoneName = !timeZoneNames.metazone |
| 224 | ? {} |
nothing calls this directly
no test coverage detected