CalendarDateFields
Represents the primary date and time fields of a CalendarDate. Can be used to set individual fields, or fetch all fields, of a date instance.
Syntax
{ year, month, day, hour, minute, second, millis, zoneId }
Properties
year: number
- Extended year
month: number
- Month
day: number
- Day of month
hour: number
- Hour 0-23
minute: number
- Minute 0-59
second: number
- Second 0-59
millis: number
- Milliseconds 0-999
zoneId: string
- Timezone identifier
Example
const cldr = framework.get('en');
const fieldsets: CalendarDateFields = [
{ year: 1994, day: 17, zoneId: 'America/New_York' },
{ year: 2020, hour: 15, second: 33 },
{ zoneId: 'America/Yellowknife' },
{ millis: 555 },
];
let date: CalendarDate;
for (const f of fieldsets) {
date = cldr.Calendars.newGregorianDate(f);
log(date);
}
log();
date = cldr.Calendars.newGregorianDate({
year: 2020,
month: 7,
day: 15,
hour: 17,
minute: 45,
second: 10,
millis: 123,
zoneId: 'America/New_York',
});
log(date.fields());
Gregorian 1994-01-17 00:00:00.000 America/New_York Gregorian 2020-01-01 15:00:33.000 Etc/UTC Gregorian 1970-01-01 00:00:00.000 America/Yellowknife Gregorian 1970-01-01 00:00:00.555 Etc/UTC { year: 2020, month: 7, day: 15, hour: 17, minute: 45, second: 10, millis: 123, zoneId: 'America/New_York' }