View Source Machete.NaiveDateTimeMatcher (Machete v0.3.0)
Defines a matcher that matches NaiveDateTime values
Summary
Types
Describes the arguments that can be passed to this matcher
Describes an instance of this matcher
Functions
Matches against NaiveDateTime values
Types
@type opts() :: [ precision: 0..6, exactly: NaiveDateTime.t(), roughly: NaiveDateTime.t() | :now, before: NaiveDateTime.t() | :now, after: NaiveDateTime.t() | :now ]
Describes the arguments that can be passed to this matcher
@opaque t()
Describes an instance of this matcher
Functions
Matches against NaiveDateTime values
Takes the following arguments:
precision
: Requires the matched NaiveDateTime to have the specified microsecond precisionexactly
: Requires the matched NaiveDateTime to be exactly equal to the specified NaiveDateTimeroughly
: Requires the matched NaiveDateTime to be within +/- 10 seconds of the specified NaiveDateTime. The atom:now
can be used to use the current time as the specified NaiveDateTimebefore
: Requires the matched NaiveDateTime to be before or equal to the specified NaiveDateTime. The atom:now
can be used to use the current time as the specified NaiveDateTimeafter
: Requires the matched NaiveDateTime to be after or equal to the specified NaiveDateTime. The atom:now
can be used to use the current time as the specified NaiveDateTime
Examples:
iex> assert NaiveDateTime.utc_now() ~> naive_datetime()
true
iex> assert NaiveDateTime.utc_now() ~> naive_datetime(precision: 6)
true
iex> assert ~N[2020-01-01 00:00:00.000000] ~> naive_datetime(exactly: ~N[2020-01-01 00:00:00.000000])
true
iex> assert NaiveDateTime.utc_now() ~> naive_datetime(roughly: :now)
true
iex> assert ~N[2020-01-01 00:00:00.000000] ~> naive_datetime(roughly: ~N[2020-01-01 00:00:05.000000])
true
iex> assert ~N[2020-01-01 00:00:00.000000] ~> naive_datetime(before: :now)
true
iex> assert ~N[2020-01-01 00:00:00.000000] ~> naive_datetime(before: ~N[3000-01-01 00:00:00.000000])
true
iex> assert ~N[3000-01-01 00:00:00.000000] ~> naive_datetime(after: :now)
true
iex> assert ~N[3000-01-01 00:00:00.000000] ~> naive_datetime(after: ~N[2020-01-01 00:00:00.000000])
true