# `Machete.UnixTimeMatcher`
[🔗](https://github.com/mtrudel/machete/blob/main/lib/machete/matchers/unix_time_matcher.ex#L1)

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

# `opts`

```elixir
@type opts() :: [
  exactly: integer(),
  roughly: integer() | :now,
  epsilon: integer() | {integer(), integer()},
  before: integer() | :now,
  after: integer() | :now
]
```

Describes the arguments that can be passed to this matcher

# `t`

```elixir
@opaque t()
```

Describes an instance of this matcher

# `unix_time`

```elixir
@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 `epsilon` seconds of the specified Unix
  time. The atom `:now` can be used to use the current time as the specified Unix time
* `epsilon`: The bound(s) to use when determining how close (in milliseconds) the matched Unix
  time needs to be to `roughly`. 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 10_000 milliseconds
* `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(roughly: 1681060001000, epsilon: 1000)
    true

    iex> assert 1681060000000 ~> unix_time(roughly: 1681060001000, epsilon: {1000, 500})
    true

    iex> refute 1681060000000 ~> unix_time(roughly: 1681060001001, epsilon: 1000)
    false

    iex> refute 1681060000000 ~> unix_time(roughly: 1681060001001, epsilon: {1000, 500})
    false

    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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
