Cldr.DateTime.Formatter.related_year
related_year
, go back to Cldr.DateTime.Formatter module for more information.
Specs
related_year(Calendar.date(), integer(), Keyword.t()) :: String.t() | {:error, String.t()}
Returns the related gregorian year (format symbol r
)
of a date for given locale.
Arguments
date
is aDate
struct or any map that contains at least the keys:month
and:calendar
n
in an integer between 1 and 5 that determines the format of the quarterlocale
is any valid locale name returned byCldr.known_locale_names/0
or aCldr.LanguageTag
struct. The default isCldr.get_locale/0
options
is aKeyword
list of options. There are no options used inrelated_year/4
Format Symbol
The representation of the related year is made in accordance with the following table:
Symbol | Example | Cldr Format |
---|---|---|
r+ | 2017 |
This corresponds to the extended Gregorian year in which the calendar’s year begins. Related Gregorian years are often displayed, for example, when formatting dates in the Japanese calendar — e.g. “2012(平成24)年1月15日” — or in the Chinese calendar — e.g. “2012壬辰年腊月初四”. The related Gregorian year is usually displayed using the ":latn" numbering system, regardless of what numbering systems may be used for other parts of the formatted date.
If the calendar’s year is linked to the solar year (perhaps using leap months), then for that calendar the ‘r’ year will always be at a fixed offset from the ‘u’ year.
For the Gregorian calendar, the ‘r’ year is the same as the ‘u’ year. For ‘r’, all field lengths specify a minimum number of digits; there is no special interpretation for “rr”.
Specs
related_year(Calendar.date(), integer(), locale(), Cldr.backend(), Keyword.t()) :: String.t() | {:error, String.t()}