CalendarExt (calendar_ext v0.1.8)

Copy Markdown View Source

Summary

Functions

Calculates the week number of week days between from_date and to_date.

Returns the earliest date.

Returns the latest date

Converts dateable to %Date{}. It will return nil for nil values.

Returns the morning of NaiveDateTime.utc_now().

Types

calendar_ext()

@type calendar_ext() :: Date.t() | DateTime.t() | NaiveDateTime.t()

dateable()

@type dateable() :: Date.t() | DateTime.t() | NaiveDateTime.t()

nillable_date()

@type nillable_date() :: Date.t() | nil

Functions

diff_weekdays(from_date, to_date)

@spec diff_weekdays(dateable(), dateable()) :: integer()

Calculates the week number of week days between from_date and to_date.

Examples

iex> CalendarExt.diff_weekdays(~D[2020-10-10], ~D[2020-10-20]) 6

It will return 0 if the second date is in the past

iex> CalendarExt.diff_weekdays(~D[2020-10-10], ~D[2020-08-20]) 0

max(left, right)

Returns the earliest date.

min(left, right)

Returns the latest date

outside?(date, start_date, end_date)

to_date(date)

@spec to_date(dateable()) :: nillable_date()

Converts dateable to %Date{}. It will return nil for nil values.

to_naive_with_invalid_time(date_string, default_offset \\ "Z")

utc_morning()

@spec utc_morning() :: NaiveDateTime.t()

Returns the morning of NaiveDateTime.utc_now().