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

Defines a matcher that matches Date values

# `opts`

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

Describes the arguments that can be passed to this matcher

# `t`

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

Describes an instance of this matcher

# `date`

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

Matches against Date values

Takes the following arguments:

* `exactly`: Requires the matched Date to be exactly equal to the specified Date. The atom `:today` can
  be used to use today as the specified Date
* `roughly`: Requires the matched Date to be within `epsilon` days of the specified Date. The atom
  `:today` can be used to use today as the specified Date
* `epsilon`: The bound(s) to use when determining how close (in days) the matched Date 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 1 day
* `before`: Requires the matched Date to be before or equal to the specified Date. The atom
  `:today` can be used to use today as the specified Date
* `after`: Requires the matched Date to be after or equal to the specified Date. The atom
  `:today` can be used to use today as the specified Date

Examples:

    iex> assert Date.utc_today() ~> date()
    true

    iex> assert Date.utc_today() ~> date(exactly: :today)
    true

    iex> assert ~D[2020-01-01] ~> date(exactly: ~D[2020-01-01])
    true

    iex> assert Date.utc_today() ~> date(roughly: :today)
    true

    iex> assert ~D[2020-01-01] ~> date(roughly: ~D[2020-01-02])
    true

    iex> assert ~D[2020-01-01] ~> date(roughly: ~D[2020-01-03], epsilon: 2)
    true

    iex> assert ~D[2020-01-01] ~> date(roughly: ~D[2020-01-03], epsilon: {2, 1})
    true

    iex> refute ~D[2020-01-01] ~> date(roughly: ~D[2020-01-04], epsilon: 2)
    false

    iex> refute ~D[2020-01-01] ~> date(roughly: ~D[2020-01-04], epsilon: {2, 1})
    false

    iex> assert ~D[2020-01-01] ~> date(before: :today)
    true

    iex> assert ~D[2020-01-01] ~> date(before: ~D[3000-01-01])
    true

    iex> assert ~D[3000-01-01] ~> date(after: :today)
    true

    iex> assert ~D[3000-01-01] ~> date(after: ~D[2020-01-01])
    true

---

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