Cldr.Calendar.Kday.nth_kday
You're seeing just the function
nth_kday
, go back to Cldr.Calendar.Kday module for more information.
Specs
nth_kday(Calendar.day() | Date.t(), integer(), Cldr.Calendar.day_of_week()) :: Calendar.day() | Date.t()
Return the date of the nth
day_of_week
on or before/after the
specified date
.
Arguments
date
is%Date{}
, a%DateTime{}
,%NaiveDateTime{}
or a Rata Dien
is the cardinal number ofk
before (negativen
) or after (positiven
) the specified datek
is an integer day of the week.
Returns
- A
%Date{}
in the calendar of the date provided as an argument
Examples
# Thanksgiving in the US
iex> Cldr.Calendar.Kday.nth_kday(~D[2017-11-01], 4, 4)
~D[2017-11-23]
# Labor day in the US
iex> Cldr.Calendar.Kday.nth_kday(~D[2017-09-01], 1, 1)
~D[2017-09-04]
# Daylight savings time starts in the US
iex> Cldr.Calendar.Kday.nth_kday(~D[2017-03-01], 2, 7)
~D[2017-03-12]