Cldr.Calendar.Kday.kday_before

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

Specs

Return the date of the day_of_week before the specified date.

Arguments

  • date is %Date{}, a %DateTime{}, %NaiveDateTime{} or a Rata Die

  • k is an integer day of the week.

Returns

  • A %Date{} in the calendar of the date provided as an argument

Examples

iex> Cldr.Calendar.Kday.kday_before(~D[2016-02-29], 2)
~D[2016-02-23]

iex> Cldr.Calendar.Kday.kday_before(~D[2017-11-30], 1)
~D[2017-11-27]

# 6 means Saturday.  Use either the integer value or the atom form.
iex> Cldr.Calendar.Kday.kday_before(~D[2017-06-30], 6)
~D[2017-06-24]