Cldr.Calendar.weekend-question-mark
weekend-question-mark
, go back to Cldr.Calendar module for more information.
Specs
Returns whether a given date is a weekend day.
Weekend days are locale-specific and depend on the policies of a given territory (country).
Arguments
date
is anyDate.t()
options
is a Keyword list of options
Options
:locale
is any locale or locale name validated byCldr.validate_locale/2
. The default isCldr.get_locale()
which returns the locale set for the current process:territory
is any valid ISO-3166-2 territory that is validated byCldr.validate_territory/1
:backend
is anyCldr
backend module. See the backend configuration documentation for further information. The default isCldr.Calendar.Backend.Default
which configures only theen
locale.
Notes
When identifying which territory context within which to determine whether a given day is a weekend or not the following order applies:
A territory specified by the
:territory
optionThe territory defined as part of the
:locale
optionThe territory defined as part of the current processes default locale.
Examples
# The defalt locale for `Cldr` is `en-001` for which
# the territory is `001` (the world). The weekend
# for `001` is Saturday and Sunday
iex> Cldr.Calendar.weekend? ~D[2019-03-23]
true
iex> Cldr.Calendar.weekend? ~D[2019-03-23], locale: "en"
true
iex> Cldr.Calendar.weekend? ~D[2019-03-23], territory: "IS"
true
# In India the official weekend is only Sunday
iex> Cldr.Calendar.weekend? ~D[2019-03-23], locale: "en-IN", backend: MyApp.Cldr
false
# In Israel the weekend starts on Friday
iex> Cldr.Calendar.weekend? ~D[2019-03-22], locale: "he", backend: MyApp.Cldr
true
# As it also does in Saudia Arabia
iex> Cldr.Calendar.weekend? ~D[2019-03-22], locale: "ar-SA", backend: MyApp.Cldr
true
# Sunday is not a weekend day in Saudi Arabia
iex> Cldr.Calendar.weekend? ~D[2019-03-24], locale: "ar-SA", backend: MyApp.Cldr
false