Cldr.DateTime.Formatter.week_aligned_year
week_aligned_year
, go back to Cldr.DateTime.Formatter module for more information.
Specs
week_aligned_year(Calendar.date(), integer(), Keyword.t()) :: String.t() | {:error, String.t()}
Returns the year
(format symbol Y
) in “Week of Year”
based calendars in which the year transition occurs
on a week boundary.
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 yearlocale
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 inweeK_aligned_year/4
Format Symbol
The representation of the year is made in accordance with the following table:
Symbol | Example | Cldr Format |
---|---|---|
Y | 7 | Minimum necessary digits |
YY | "17" | Least significant 2 digits |
YYY | "017", "2017" | Padded to at least 3 digits |
YYYY | "2017" | Padded to at least 4 digits |
YYYYY | "02017" | Padded to at least 5 digits |
The result may differ from calendar year ‘y’ near a year transition. This numeric year designation is used in conjunction with pattern character ‘w’ in the ISO year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems where week date processing is desired.
The field length is interpreted in the same was as for
y
; that is, yy
specifies use of the two low-order
year digits, while any other field length specifies a
minimum number of digits to display.
Examples
iex> Cldr.DateTime.Formatter.week_aligned_year ~D[2017-01-04], 1
"2017"
iex> Cldr.DateTime.Formatter.week_aligned_year ~D[2017-01-04], 2
"17"
iex> Cldr.DateTime.Formatter.week_aligned_year ~D[2017-01-04], 3
"2017"
iex> Cldr.DateTime.Formatter.week_aligned_year ~D[2017-01-04], 4
"2017"
iex> Cldr.DateTime.Formatter.week_aligned_year ~D[2017-01-04], 5
"02017"
Specs
week_aligned_year( Calendar.date(), integer(), locale(), Cldr.backend(), Keyword.t() ) :: String.t() | {:error, String.t()}