View Source Machete.TimeMatcher (Machete v0.3.0)
Defines a matcher that matches Time values
Summary
Types
Describes the arguments that can be passed to this matcher
Describes an instance of this matcher
Functions
Matches against Time values
Types
Functions
Matches against Time values
Takes the following arguments:
precision
: Requires the matched Time to have the specified microsecond precisionexactly
: Requires the matched Time to be exactly equal to the specified Timeroughly
: Requires the matched Time to be within +/- 10 seconds of the specified Time. The atom:now
can be used to use the current time as the specified Timebefore
: Requires the matched Time to be before or equal to the specified Time. The atom:now
can be used to use the current time as the specified Timeafter
: Requires the matched Time to be after or equal to the specified Time. The atom:now
can be used to use the current time as the specified Time
Examples:
iex> assert Time.utc_now() ~> time()
true
iex> assert Time.utc_now() ~> time(precision: 6)
true
iex> assert ~T[00:00:00.000000] ~> time(exactly: ~T[00:00:00.000000])
true
iex> assert Time.utc_now() ~> time(roughly: :now)
true
iex> assert ~T[00:00:00.000000] ~> time(roughly: ~T[00:00:05.000000])
true
iex> assert ~T[00:00:00.000000] ~> time(before: :now)
true
iex> assert ~T[00:00:00.000000] ~> time(before: ~T[00:00:01.000000])
true
iex> assert ~T[23:59:59.999999] ~> time(after: :now)
true
iex> assert ~T[00:00:01.000000] ~> time(after: ~T[00:00:00.000000])
true