Cldr.DateTime.Formatter.week_aligned_year

You're seeing just the function week_aligned_year, go back to Cldr.DateTime.Formatter module for more information.
Link to this function

week_aligned_year(week_aligned_year, n \\ 1, options \\ [])

View Source

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 a Date 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 year

  • locale is any valid locale name returned by Cldr.known_locale_names/0 or a Cldr.LanguageTag struct. The default is Cldr.get_locale/0

  • options is a Keyword list of options. There are no options used in weeK_aligned_year/4

Format Symbol

The representation of the year is made in accordance with the following table:

SymbolExampleCldr Format
Y7Minimum 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"
Link to this function

week_aligned_year(date, n, locale, backend, options \\ [])

View Source

Specs

week_aligned_year(
  Calendar.date(),
  integer(),
  locale(),
  Cldr.backend(),
  Keyword.t()
) :: String.t() | {:error, String.t()}