Cldr.DateTime.Formatter.week_of_year
week_of_year
, go back to Cldr.DateTime.Formatter module for more information.
Specs
week_of_year(Calendar.date(), integer(), Keyword.t()) :: String.t() | {:error, String.t()}
Returns the week of the year (symbol w
) as an integer.
Arguments
date
is aDate
struct or any map that contains at least the keys:year
,:month
,:day
and:calendar
n
in an integer between 1 and 2 that determines the format of the week 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_of_year/4
Notes
Determining the week of the year is influenced by two factors:
The calendar in use. For example the ISO calendar (which is the default calendar in Elixir) follows the ISO standard in which the first week of the year is the week containing the first thursday of the year.
The territory in use. For example, in the US the first week of the year is the week containing January 1st whereas many territories follow the ISO standard.
Format Symbol
The representation of the day of the year is made in accordance with the following table:
Symbol | Example | Cldr Format |
---|---|---|
w | 2, 22 | |
ww | 02, 22 |
Examples
iex> import Cldr.Calendar.Sigils
Cldr.Calendar.Sigils
iex> Cldr.DateTime.Formatter.week_of_year ~D[2019-01-07], 1
"2"
iex> Cldr.DateTime.Formatter.week_of_year ~d[2019-W04-1], 2
"04"
Specs
week_of_year(Calendar.date(), integer(), locale(), Cldr.backend(), Keyword.t()) :: String.t() | {:error, String.t()}