Cldr.Calendar.minus

You're seeing just the function minus, go back to Cldr.Calendar module for more information.
Link to this function

minus(date, period, amount, options \\ [])

View Source

Decrements a date or date range by an integer amount of a date period (year, quarter, month, week or day).

Arguments

  • date_or_date_range is any Date.t or Date.Range.t

  • period is :year, :quarter, :month, :week or :day

  • options is a Keyword list of options

Options

  • :coerce is a boolean which, when set to true will coerce the month and/or day to be a valid date. This affects,for example, moving to the previous month from ~D[2019-03-31]. Sincce there is no date ~D[2019-02-31] this would normally return {:error, :invalid_date}. Setting coerce: true it will return ~D[2019-02-28].

Returns

When a Date.t is passed, a Date.t is returned. When a Date.Range.t is passed a Date.Range.t is returned.

Examples

iex> Cldr.Calendar.minus ~D[2016-03-01], :days, 1
~D[2016-02-29]

iex> Cldr.Calendar.minus ~D[2019-03-01], :months, 1
~D[2019-02-01]

iex> Cldr.Calendar.minus ~D[2016-03-01], :days, 1
~D[2016-02-29]

iex> Cldr.Calendar.minus ~D[2019-03-01], :days, 1
~D[2019-02-28]

iex> Cldr.Calendar.minus ~D[2019-03-01], :months, 1
~D[2019-02-01]

iex> Cldr.Calendar.minus ~D[2019-03-01], :quarters, 1
~D[2018-12-01]

iex> Cldr.Calendar.minus ~D[2019-03-01], :years, 1
~D[2018-03-01]