Cldr.Calendar.Kday.nth_kday

You're seeing just the function nth_kday, go back to Cldr.Calendar.Kday module for more information.

Specs

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 Die

  • n is the cardinal number of k before (negative n) or after (positive n) the specified date

  • k 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]