mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(common): improve dayPeriods-related types in generate-locales-tool (#45714)
Update some TypeScript types in `generate-locales-tool/day-periods.ts` to more closely reflect the actual shapes of the returned objects. Examples of the related raw JSON data for the `en` locale can be seen here: - [dayPeriods][1] - [dayPeriodRules][2] [1]: https://github.com/unicode-org/cldr-json/blob/41.0.0/cldr-json/cldr-dates-full/main/en/ca-gregorian.json#L223-L300 [2]: https://github.com/unicode-org/cldr-json/blob/41.0.0/cldr-json/cldr-core/supplemental/dayPeriods.json#L404-L427 PR Close #45714
This commit is contained in:
committed by
Dylan Hunn
parent
0e5e4e298a
commit
521bfc127c
@@ -12,8 +12,16 @@ import {CldrLocaleData} from './cldr-data';
|
||||
* Returns data for the chosen day periods
|
||||
*/
|
||||
export function getDayPeriods(localeData: CldrLocaleData, dayPeriodsList: string[]): {
|
||||
format: {narrow: string[], abbreviated: string[], wide: string[]},
|
||||
'stand-alone': {narrow: string[], abbreviated: string[], wide: string[]}
|
||||
format: {
|
||||
narrow: Record<string, string>,
|
||||
abbreviated: Record<string, string>,
|
||||
wide: Record<string, string>
|
||||
},
|
||||
'stand-alone': {
|
||||
narrow: Record<string, string>,
|
||||
abbreviated: Record<string, string>,
|
||||
wide: Record<string, string>
|
||||
}
|
||||
} {
|
||||
const dayPeriods = localeData.main(`dates/calendars/gregorian/dayPeriods`);
|
||||
const result: any = {};
|
||||
@@ -39,7 +47,8 @@ export function getDayPeriods(localeData: CldrLocaleData, dayPeriodsList: string
|
||||
* @returns string[]
|
||||
*/
|
||||
export function getDayPeriodRules(
|
||||
localeData: CldrLocaleData, language = localeData.attributes.language): {[key: string]: []} {
|
||||
localeData: CldrLocaleData,
|
||||
language = localeData.attributes.language): Record<string, string|[string, string]> {
|
||||
const dayPeriodRules = localeData.get(`supplemental/dayPeriodRuleSet/${language}`);
|
||||
const rules: any = {};
|
||||
if (dayPeriodRules) {
|
||||
|
||||
Reference in New Issue
Block a user