formatPartial
Formats a partial ISO date at the precision it was given, in UTC: a year alone is
approximate and reads c. 2008, a month Mar 2008 and a full day Mar 9, 2008.
Month names and their order follow locale. The marker before a year alone does not: see
FormatPartialOptions.
Returns null when parsePartial would, or when the locale is invalid.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input | string | A `YYYY`, `YYYY-MM` or `YYYY-MM-DD` string |
options | FormatPartialOptions | Locale and approximate-year marker — see FormatPartialOptions |
Returns
Section titled “Returns”string | null — The label, or null
Examples
Section titled “Examples”Label at the known precision
Section titled “Label at the known precision”An approximate year reads “c. 2008”, a month “Mar 2008”, a day “Mar 9, 2008”.
Another language
Section titled “Another language”The locale sets the month names; the marker for a year alone is a word, so you give it.
Invalid input
Section titled “Invalid input”Returns null instead of a wrong label.
Related Types
Section titled “Related Types”FormatPartialOptions
Section titled “FormatPartialOptions”Options for formatPartial.
