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

Defines a matcher that matches NaiveDateTime values

# `opts`

```elixir
@type opts() :: [
  precision: 0..6,
  exactly: NaiveDateTime.t(),
  roughly: NaiveDateTime.t() | :now,
  epsilon: integer() | {integer(), integer()},
  before: NaiveDateTime.t() | :now,
  after: NaiveDateTime.t() | :now
]
```

Describes the arguments that can be passed to this matcher

# `t`

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

Describes an instance of this matcher

# `naive_datetime`

```elixir
@spec naive_datetime(opts()) :: t()
```

Matches against NaiveDateTime values

Takes the following arguments:

* `precision`: Requires the matched NaiveDateTime to have the specified microsecond precision
* `exactly`: Requires the matched NaiveDateTime to be exactly equal to the specified NaiveDateTime
* `roughly`: Requires the matched NaiveDateTime to be within `epsilon` seconds of the specified
   NaiveDateTime. The atom `:now` can be used to use the current time as the specified
   NaiveDateTime
* `epsilon`: The bound(s) to use when determining how close (in microseconds) the matched
  NaiveDateTime 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_000 microseconds (10 seconds)
* `before`: 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
  NaiveDateTime
* `after`: 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(roughly: ~N[2020-01-01 00:00:10.000000], epsilon: 10000000)
    true

    iex> assert ~N[2020-01-01 00:00:00.000000] ~> naive_datetime(roughly: ~N[2020-01-01 00:00:10.000000], epsilon: {10000000, 5000000})
    true

    iex> refute ~N[2020-01-01 00:00:00.000000] ~> naive_datetime(roughly: ~N[2020-01-01 00:00:10.000001], epsilon: 10000000)
    false

    iex> refute ~N[2020-01-01 00:00:00.000000] ~> naive_datetime(roughly: ~N[2020-01-01 00:00:10.000001], epsilon: {10000000, 5000000})
    false

    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

---

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