Koyomi.Month (Koyomi v0.2.1)

Copy Markdown View Source

An Ecto type for a month, stored in a :date column as the first day of the month.

field :billing_month, Koyomi.Month

The month picker posts YYYY-MM ("2027-03"), as the browser's own month input does. The type casts it, a Date (any day of the month) and a map with "year" and "month". The value is the first day of the month: ~D[2027-03-01].

Summary

Functions

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Writes a month as YYYY-MM.

Functions

embed_as(_)

Callback implementation for Ecto.Type.embed_as/1.

equal?(term1, term2)

Callback implementation for Ecto.Type.equal?/2.

to_iso8601(date)

@spec to_iso8601(Date.t()) :: String.t()

Writes a month as YYYY-MM.

Examples

iex> Koyomi.Month.to_iso8601(~D[2027-03-15])
"2027-03"