View Source Machete.UnixTimeMatcher (Machete v0.3.1)

Defines a matcher that matches integers that represent Unix time in milliseconds

Summary

Types

Describes the arguments that can be passed to this matcher

t()

Describes an instance of this matcher

Functions

Matches against integers that represent Unix time values in milliseconds

Types

@type opts() :: [
  exactly: integer(),
  roughly: integer() | :now,
  before: integer() | :now,
  after: integer() | :now
]

Describes the arguments that can be passed to this matcher

@opaque t()

Describes an instance of this matcher

Functions

@spec unix_time(opts()) :: t()

Matches against integers that represent Unix time values in milliseconds

Takes the following arguments:

  • exactly: Requires the matched Unix time to be exactly equal to the specified Unix time
  • roughly: Requires the matched Unix time to be within +/- 10 seconds of the specified Unix time. The atom :now can be used to use the current time as the specified Unix time
  • before: Requires the matched Unix time to be before or equal to the specified Unix time. The atom :now can be used to use the current time as the specified Unix time
  • after: Requires the matched Unix time to be after or equal to the specified Unix time. The atom :now can be used to use the current time as the specified Unix time

Examples:

iex> assert :os.system_time(:millisecond) ~> unix_time()
true

iex> assert 1681060000000 ~> unix_time(exactly: 1681060000000)
true

iex> assert :os.system_time(:millisecond) ~> unix_time(roughly: :now)
true

iex> assert 1681060000000 ~> unix_time(roughly: 1681060005000)
true

iex> assert 1681060000000 ~> unix_time(before: :now)
true

iex> assert 1681060000000 ~> unix_time(before: 1681090000000)
true

iex> assert 9991090000000 ~> unix_time(after: :now)
true

iex> assert 1681060000000 ~> unix_time(after: 0)
true