# `DayEx`
[🔗](https://github.com/gsmlg-opt/backplane/blob/v1.10.115/apps/day_ex/lib/day_ex.ex#L1)

Lightweight Elixir port of dayjs.

Pipe-friendly date/time parsing, formatting, manipulation, and querying.
All functions accept `%DayEx{}` as the first argument.

Months are 1-indexed (differs from dayjs 0-indexed).

# `t`

```elixir
@type t() :: %DayEx{datetime: DateTime.t() | NaiveDateTime.t(), locale: atom()}
```

# `add`

# `after?`

# `after?`

# `before?`

# `before?`

# `between?`

# `between?`

# `between?`

# `calendar`

Formats a calendar label relative to the reference date. See `DayEx.Calendar.calendar/3`.

# `compare`

# `date`

# `date`

# `day`

# `day_of_year`

# `day_of_year`

# `days_in_month`

```elixir
@spec days_in_month(t()) :: 28..31
```

Returns the number of days in the value's Gregorian calendar month.

# `diff`

# `diff`

# `diff`

# `end_of`

# `format`

# `format`

# `from`

# `from`

# `from_lunar`

```elixir
@spec from_lunar(DayEx.Lunar.t()) :: {:ok, t()} | {:error, DayEx.Lunar.error()}
```

Converts a Chinese lunar date to a DayEx value at Gregorian civil midnight.

# `from_lunar`

```elixir
@spec from_lunar(integer(), integer(), integer(), [{:leap_month, boolean()}]) ::
  {:ok, t()} | {:error, DayEx.Lunar.error()}
```

Constructs a DayEx value from numbered lunar fields. Pass `leap_month: true`
to select the second occurrence of a repeated month.

# `from_now`

# `from_now`

# `hour`

# `hour`

# `iso_week`

# `iso_week`

# `iso_week_year`

# `leap_year?`

# `local`

# `locale`

# `max`

# `millisecond`

# `millisecond`

# `min`

# `minute`

# `minute`

# `month`

# `month`

# `now`

# `now`

# `parse`

# `parse`

# `parse`

# `parse!`

# `parse!`

# `quarter`

# `quarter`

# `same?`

# `same?`

# `same_or_after?`

# `same_or_after?`

# `same_or_before?`

# `same_or_before?`

# `second`

# `second`

# `set`

# `start_of`

# `subtract`

# `to`

# `to`

# `to_date`

# `to_datetime`

# `to_iso_string`

# `to_json`

# `to_list`

# `to_lunar`

```elixir
@spec to_lunar(t() | Date.t() | NaiveDateTime.t() | DateTime.t()) ::
  {:ok, DayEx.Lunar.t()} | {:error, :out_of_range}
```

Converts a DayEx value or native date/time to a Chinese lunar date.

Instants use Beijing standard time (UTC+08:00). Dates and naive datetimes
supply the civil date directly. See `DayEx.Lunar.supported_range/0`.

# `to_map`

# `to_naive_datetime`

# `to_now`

# `to_now`

# `to_unix`

# `to_unix_millisecond`

# `today?`

Tests whether the value falls on the reference day, defaulting to today.

# `tomorrow?`

Tests whether the value falls on the civil day after the reference.

# `tz`

# `tz_name`

# `unix`

# `utc`

# `utc`

# `utc?`

# `utc_offset`

# `valid?`

# `week`

# `week`

# `week_year`

# `weekday`

# `weekday`

# `weeks_in_year`

# `year`

# `year`

# `yesterday?`

Tests whether the value falls on the civil day before the reference.

---

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