Machete.DateMatcher (Machete v0.3.11)
View SourceDefines a matcher that matches Date values
Summary
Types
Describes the arguments that can be passed to this matcher
Describes an instance of this matcher
Functions
Matches against Date values
Types
Functions
Matches against Date values
Takes the following arguments:
exactly
: Requires the matched Date to be exactly equal to the specified Date. The atom:today
can be used to use today as the specified Dateroughly
: Requires the matched Date to be withinepsilon
days of the specified Date. The atom:today
can be used to use today as the specified Dateepsilon
: The bound(s) to use when determining how close (in days) the matched Date needs to be toroughly
. Can be specified as a single integer that is used for both lower and upper bounds, or a tuple consisting of distinct lower and upper bounds. If not specified, defaults to 1 daybefore
: Requires the matched Date to be before or equal to the specified Date. The atom:today
can be used to use today as the specified Dateafter
: Requires the matched Date to be after or equal to the specified Date. The atom:today
can be used to use today as the specified Date
Examples:
iex> assert Date.utc_today() ~> date()
true
iex> assert Date.utc_today() ~> date(exactly: :today)
true
iex> assert ~D[2020-01-01] ~> date(exactly: ~D[2020-01-01])
true
iex> assert Date.utc_today() ~> date(roughly: :today)
true
iex> assert ~D[2020-01-01] ~> date(roughly: ~D[2020-01-02])
true
iex> assert ~D[2020-01-01] ~> date(roughly: ~D[2020-01-03], epsilon: 2)
true
iex> assert ~D[2020-01-01] ~> date(roughly: ~D[2020-01-03], epsilon: {2, 1})
true
iex> refute ~D[2020-01-01] ~> date(roughly: ~D[2020-01-04], epsilon: 2)
false
iex> refute ~D[2020-01-01] ~> date(roughly: ~D[2020-01-04], epsilon: {2, 1})
false
iex> assert ~D[2020-01-01] ~> date(before: :today)
true
iex> assert ~D[2020-01-01] ~> date(before: ~D[3000-01-01])
true
iex> assert ~D[3000-01-01] ~> date(after: :today)
true
iex> assert ~D[3000-01-01] ~> date(after: ~D[2020-01-01])
true