Constructor
new module:extdatetimeformat(localeopt, optionsopt, calendaropt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
locale |
string |
<optional> |
as for Intl.DateTimeFormat. |
options |
Object |
<optional> |
same as for Intl.DateTimeFormat + option eraDisplay : ("never"/"always"/"auto"), default to "auto": should era be displayed ? if "auto", era is displayed if year is displayed and era of now is not equal to era of formatted date. if era option is not specified, "short" is assumed whenever necessary. Note: date and time fields option values "2-digit" and "numeric" yield different effects, unlike legacy Intl.DateTimeFormat. |
calendar |
Object |
<optional> |
a calendar used to format the date. If this parameter is not specified, the calendar resolved with locale and options will be used. If specified as a built-in calendar string, this calendar supersedes the one resolved with locale and options. If specified as a custom calendar and if a Private Locale Data Repository (PLDR) is given, this will be used for calendar's entity names. If no PLDR is provided, the calendar.canvas field refers to the built-in calendar to use for entity names. |
- Version:
- M2022-08-06
- License:
- MIT 2016-2022
- Source:
- See:
-
- customcalendarmodel.js
- customcalendarmodel.js for the custom calendar model.
Requires:
- module:extdate.js
Extends
- Intl.DateTimeFormat.
Requires
- module:extdate.js
Methods
format(date) → {string}
format, from computed parts, using extended FormatToParts.
Parameters:
Name | Type | Description |
---|---|---|
date |
Object | the date to display. |
- Source:
Returns:
the string to display.
- Type
- string
formatToParts(aDate) → {Array.<Object>}
Extended FormatToParts method.
The custom calendar is used for display.
The eraDisplay option controls whether the era field is displayed.
Field asked as "numeric" are not changed to "2-digit".
In left-to-right languages, the "numeric" option fot time fields implies the " h ", " min " and " s " marks instead of ":".
Parameters:
Name | Type | Description |
---|---|---|
aDate |
Object | the date to be displayed. |
- Source:
Returns:
like the Intl.DateTimeFormat, but enhanced.
- Type
- Array.<Object>
resolvedOptions() → {Object}
the resolved options for this object, that slightly differ from those of Intl.DateTimeFormat.
- Source:
Returns:
the options revised to reflect what will be provided. eraDisplay is also resolved. hour12 is never returned.
- Type
- Object
(static) dateFieldNames() → {Array.<string>}
The names of the fields necessary to fully characterise a date in any calendar.
- Source:
Returns:
the names of the minimum fields necessary for an unambiguous date.
- Type
- Array.<string>
(static) weekdayKey(index) → {string}
The universal keys for the weekdays of the standard 7-days week, used in CLDR and to be used with a Private Locale Data Repository.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | 0 to 6. |
- Source:
Returns:
a three-character string for the weekday.
- Type
- string