Date

Core

A calendar day without a time of day or time zone.

Time.Posix remains the instant type (including DB columns). Convert with fromPosix / toPosix. Local midnight for zones with DST transitions may land on the previous or next civil day; prefer Time.utc or a fixed Time.customZone when you need a stable mapping.

Types

Date

type Date = Date Int

A civil calendar date (year / month / day).

Values

fromPosix

fromPosix : Zone -> Posix -> Date

Local calendar date of posix in zone.

toPosix

toPosix : Zone -> Date -> Posix

Local midnight for this date in zone, as a Posix instant.

On DST spring-forward days, midnight may not exist; the returned instant is the best-effort offset-adjusted midnight. Prefer UTC for round-trips.

fromCalendarDate

fromCalendarDate : Int -> Month -> Int -> Date

Build a date from calendar parts. Invalid dates become clamped via the day-number encoding only when the month day exists; prefer validating callers.

year

year : Date -> Int

Calendar year.

month

month : Date -> Month

Calendar month.

day

day : Date -> Int

Day of month (1–31).

compare

compare : Date -> Date -> Order

Order dates.

addDays

addDays : Int -> Date -> Date

Shift by a whole number of calendar days.

diffDays

diffDays : Date -> Date -> Int

Whole days from from to to (to - from).

toIsoString

toIsoString : Date -> String

Format as YYYY-MM-DD.