← index

Date

inherits Object

A civil calendar date — year, month, day; no time of day, no time zone. The type for birthdays, deadlines, and schedules, where "March 3rd" means March 3rd regardless of zone.

Shift it by calendar units with +: / -: (Span) — end-of-month clamped — and diff two dates with until:, which answers a calendar Span (1y 2mo 3d), not a second count. It meets the zone-aware world through DateTime: atTime:zone: / inZone: build one, DateTime#date extracts.

var d = Date.year:2024 month:1 day:31
(d + (Span.months:1)).s     "* -> 2024-02-29
d.weekday                   "* -> 'Wednesday'
extended at core/16-serialize.qn:28

The civil date, as ISO 8601 ('2026-07-11'; Date.parse: reads it back).

Class methods

parse:String

The date an ISO 8601 string ('2026-07-11') denotes; not parseable → ValueError.

(Date.parse:'2026-07-11').day     "* -> 11

native

today

Today's date in the host's local time zone ("today" only means something in a zone — for another zone use todayIn:).

native

todayIn:TimeZone

Today's date in the given zone: Date.todayIn:(TimeZone.of:'Asia/Tokyo').

native

year:Integer month:Integer day:Integer

The calendar date with the given components. A date that does not exist (month 13, February 30th) throws a ValueError rather than normalizing.

(Date.year:2026 month:7 day:11).s     "* -> 2026-07-11

native

Instance methods

+:Span

The date a calendar Span later — month arithmetic clamps to the end of a shorter month. Leaving jiff's supported range (years ±9999) throws an ArithmeticError.

((Date.year:2024 month:1 day:31) + (Span.months:1)).s     "* -> 2024-02-29

native

-:Span

The date a calendar Span earlier — +: in reverse.

native

<:Date

Whether the receiver is the earlier date. Only <: is native; >: / <=: / >=: derive from it on Object.

native

==:

Whether the argument is the same calendar date. A non-Date is simply unequal.

native

asData

core/16-serialize.qn:29

atTime:Time zone:TimeZone

The zone-aware DateTime at this date and wall-clock time in a zone. A time that does not exist in that zone (a DST gap) resolves per jiff's compatible rule (shifted by the gap) rather than erroring.

((Date.parse:'2026-07-11').atTime:(Time.hour:9 minute:40) zone:(TimeZone.of:'UTC')).s
"* -> 2026-07-11T09:40:00+00:00[UTC]

native

day

The day-of-month component (1-based).

native

dayOfYear

The 1-based ordinal day within the year (1–366).

native

daysInMonth

How many days this date's month has.

(Date.parse:'2024-02-10').daysInMonth     "* -> 29

native

inZone:TimeZone

The DateTime at this date's first instant (usually midnight — later where DST skips it) in a zone.

native

leapYear?

Whether this date's year is a leap year.

native

month

The month component (1–12).

native

s

The ISO 8601 date string.

(Date.year:2026 month:7 day:11).s     "* -> 2026-07-11

native

until:Date

The calendar Span from the receiver to the argument (negative when the argument is earlier), in years/months/days — the diff Duration can't express.

((Date.parse:'2024-01-15').until:(Date.parse:'2026-03-18')).s     "* -> 2y 2mo 3d

native

weekday

The day of the week, as its English name.

(Date.parse:'2026-07-11').weekday     "* -> 'Saturday'

native

year

The year component.

native