Class: module:extdatetimeformat

module:extdatetimeformat(localeopt, optionsopt, calendaropt)

ExtDateTimeFormat (default exported class): Extension of Intl.DateTimeFormat object. Handle built-in or custom calendars. Handle Private Locale Data Repositories, with same structure as Unicode's CLDR. Handle the eraDisplay option. Handle "2-digit" and "numeric" options value in a different way. Handle the intercalary months as coded in Unicode's CLDR. Enable language-sensitive intercalary month mark. Requires module:extdate.js, which could be substituted by Temporal.

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
Author:
  • Louis A. de Fouquières https://github.com/Louis-Aime
License:
  • MIT 2016-2022
Source:
See:
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