A date, checked against the calendar.
The reference.
Every public type, function and constant, grouped by package. Generated from pkg.generated.mbti and the source's own documentation comments.
@moondate
Types
Date
structA day on the proleptic Gregorian calendar.
Proleptic means the Gregorian rules are applied before 1582 as well, which is what every interchange format in reach assumes and what makes arithmetic over the whole range uniform.
- year : Int32
- month : Int32
- day : Int32
Days since 1970-01-01, negative before it.
Howard Hinnant's days_from_civil: shift the year to start in March so the leap day falls at the end, then the month lengths follow a pattern with no table.
One date less another, as a span of whole days.
The ISO 8601 week date: the year the week belongs to, the week number, and the day of the week with Monday as 1.
The year is not always the calendar year. A week belongs to the year that holds its Thursday, so the first of January can fall in the last week of the year before — which is exactly the case a hand-rolled week number gets wrong.
The day of the week with Monday as 1 and Sunday as 7.
[Date::weekday] counts from Sunday as 0, which is what cron and C's tm_wday use; ISO counts from Monday as 1. Both are here because both are asked for, and picking one silently is how an off-by-one gets into a schedule.
The date n days after 1970-01-01, the inverse of [Date::days].
The date named by an ISO week date.
The date with that ordinal.
Days since 0001-01-01, that day being 1.
The proleptic Gregorian ordinal, which is what makes two dates subtractable without going through an epoch.
The date n days later, or earlier when n is negative.
The date n months later, clamped to the end of the month it lands in.
The thirty-first of January plus one month is the twenty-eighth or twenty-ninth of February, because there is no thirty-first. Every calendar library makes this choice and they all make the same one.
The same date with some parts replaced.
The day of the week, Sunday being 0.
1970-01-01 was a Thursday, which is where the 4 comes from.
The day of the year, the first of January being 1.
Three-way ordering from Compare: less, equal or greater.
Structural equality from Eq.
The negation of equal, from Eq.
self >= other, from Compare.
self > other, from Compare.
self <= other, from Compare.
self < other, from Compare.
Writes the text form to a logger, from Show.
The debug representation, from Debug.
The text form, as a String, from Show.
Moment
enumA point in time, in one of the four shapes a format names.
TOML 1.0.0 has exactly these four and gives them these meanings; RFC 3339 defines only Zoned. The distinction is not decoration: Plain is a wall clock, which is what an alarm or an opening time is, and turning it into an instant needs a zone nobody has supplied.
- Zoned(date~ : Date, time~ : Time, zone~ : Zone)
- Plain(date~ : Date, time~ : Time)
- Day(date~ : Date)
- Clock(time~ : Time)
A moment as an ASN.1 GeneralizedTime, which is the form DER uses from 2050 on and the one that needs no windowing rule to read back.
The same instant read in another zone.
None for the three shapes that are not instants: moving a wall clock to another zone would be inventing the zone it was written in.
A date and a time as one wall-clock moment.
zone makes it an instant instead; leaving it off keeps it a wall clock, which is what an opening time or an alarm is.
The moment in C's ctime form: Sun Nov 6 08:49:37 1994.
The day is space-padded rather than zero-padded, which is the one thing that distinguishes this form from every other.
The date out of a moment.
None for a bare time, which has no date to give.
One moment less another, for the two shapes that can be subtracted.
None when they are not comparable: an instant and a wall clock differ by an amount that depends on a zone nobody supplied, and a bare time and a bare date are not the same kind of thing.
Seconds since 1970-01-01T00:00:00Z, for a moment that names one.
None for the three shapes that do not: a wall clock, a bare date and a bare time are not instants until someone supplies the zone they are read in.
A moment as an HTTP date (RFC 9110 §5.6.7): Sun, 06 Nov 1994 08:49:37 GMT.
This is the one form a Date header may take. The two obsolete forms are read by [http] and never written, which is what §5.6.7 asks for.
The ISO week date of the moment's date.
The moment as ISO 8601 text, which is what [Show] writes.
sep is the character between the date and the time, T by default; any character works, and a space is what a log line wants.
fraction is the number of fractional-second digits, 0 to 9, truncated. Left out, it writes as many as the value needs and none for a whole second, which is Temporal's auto.
offset writes the zone the moment carries, Z for UTC and ±HH:MM for an offset; false leaves the zone off, which is Temporal's offset: "never".
The moment seconds after 1970-01-01T00:00:00Z, the inverse of [Moment::timestamp].
Reading the clock is not this package's job — it has no I/O — so a caller that wants "now" passes what its own clock said.
Days since 0001-01-01 of the moment's date.
The moment span later.
A bare date moves by whole days and a bare time wraps within the day, because that is all each of them can mean.
The same moment with some parts replaced.
The time out of a moment.
Midnight for a bare date, which is the time it names.
Seconds since the epoch as a Double, fraction included.
The nine fields of a broken-down time, in the usual order: year, month, day, hour, minute, second, weekday counted from Monday as 0, day of the year, and whether daylight saving applies — always -1 here, because that needs a zone database this package does not carry.
The Date.prototype.toISOString shape: always the UTC instant, always three fractional digits, always a trailing Z.
A moment with no zone has no instant of its own, so its wall clock is taken as UTC — the same convention [Moment::strftime] uses for a bare time.
The Date.prototype.toUTCString shape: Tue, 22 Sep 2026 05:30:05 GMT.
This is the HTTP date form [Moment::http_text] already writes, on the UTC instant, which is exactly what ECMAScript's toUTCString produces.
How far the moment's clock is from UTC.
The day of the week of the moment's date, Sunday being 0.
The zone a moment carries, or None when it carries none.
Structural equality from Eq.
The negation of equal, from Eq.
Writes the text form to a logger, from Show.
The debug representation, from Debug.
The text form, as a String, from Show.
Span
structA length of time, to the nanosecond, with no calendar attached.
A span is not a number of months: a month is not a fixed length, so adding one is a calendar operation (Date::plus_months) rather than arithmetic.
- nanos : Int64
A span made of the usual parts: days, hours, minutes, seconds and fractions.
The span with its sign dropped.
Two spans added.
The span negated.
A span of n of these.
The whole days in a span, and the seconds and nanoseconds left over — the three fields a duration is usually stored in.
The span as whole seconds, rounded towards zero.
One span less another.
The span as seconds, fraction included.
Three-way ordering from Compare: less, equal or greater.
Structural equality from Eq.
The negation of equal, from Eq.
self >= other, from Compare.
self > other, from Compare.
self <= other, from Compare.
self < other, from Compare.
The debug representation, from Debug.
Time
structA time on a twenty-four hour clock, to the nanosecond.
A second of 60 is allowed: RFC 3339 §5.6 permits it for a leap second, and a timestamp that records one is a real timestamp that a reader should not throw away.
- hour : Int32
- minute : Int32
- second : Int32
- nano : Int32
A time, checked against the clock.
Nanoseconds since midnight.
The same time with some parts replaced.
Three-way ordering from Compare: less, equal or greater.
Structural equality from Eq.
The negation of equal, from Eq.
self >= other, from Compare.
self > other, from Compare.
self <= other, from Compare.
self < other, from Compare.
Writes the text form to a logger, from Show.
The debug representation, from Debug.
The text form, as a String, from Show.
Zone
enumHow far the clock is from UTC, in minutes east of it.
Utc and Offset(0) are both midnight-at-Greenwich, but they are not the same thing to write down: RFC 3339 §4.3 gives -00:00 to a timestamp whose offset is unknown, and Z to one that is genuinely UTC.
- Utc
- Offset(Int32)
Structural equality from Eq.
The negation of equal, from Eq.
The debug representation, from Debug.
Errors
Refused
suberrorWhy an expression was refused.
- Range(field~ : String, got~ : Int32, low~ : Int32, high~ : Int32)
- Malformed(String)
- Truncated(String)
Structural equality from Eq.
The negation of equal, from Eq.
Writes the text form to a logger, from Show.
The debug representation, from Debug.
The text form, as a String, from Show.
Functions
An ASN.1 UTCTime or GeneralizedTime (ITU-T X.680 §47), as DER writes them.
This is how a certificate spells its validity. DER requires the Z and whole seconds; UTCTime's two-digit year is read as RFC 5280 §4.1.2.5.1 says — 49 and under are 2000s, 50 and over are 1900s, which is not the same rule HTTP uses.
An HTTP date read (RFC 9110 §5.6.7).
The preferred IMF-fixdate, and the two obsolete forms a recipient must still accept: RFC 850's Sunday, 06-Nov-94 08:49:37 GMT and asctime's Sun Nov 6 08:49:37 1994. A two-digit year is read as RFC 6265 §5.1.1 says: 69 and under are 2000s, 70 and over are 1900s.
Whether year has a twenty-ninth of February.
Every fourth year, except every hundredth, except every four-hundredth — the rule that makes the calendar year 365.2425 days long.
How many days month has in year.
A moment read from ISO 8601 text, which is what [parse] does.
An expression, in the five-field form crontab(5) defines or the six-field form that puts seconds in front.
┌───────────── second (0-59, six-field form only)
│ ┌───────────── minute (0-59)
│ │ ┌───────────── hour (0-23)
│ │ │ ┌───────────── day of month (1-31)
│ │ │ │ ┌───────────── month (1-12 or JAN-DEC)
│ │ │ │ │ ┌───────────── day of week (0-7 or SUN-SAT, both 0 and 7 being Sunday)
* * * * * *
Each field takes *, a number, a range a-b, a step */n or a-b/n, and a comma-separated list of those. ? reads as *, which is how a scheduler spells the day field it is not using.
The shorthands @yearly, @annually, @monthly, @weekly, @daily, @midnight and @hourly are the ones crontab(5) lists. @reboot is not here: it names an event rather than a time, and this package answers when something fires, not why.
Constants
Midnight, and the last representable moment of a day.
The earliest and latest dates this calendar writes with a four-digit year.
They are 1-01-01 and 9999-12-31, which is as far as a four-digit year writes; the arithmetic here works outside that range, so these are a convention for writing rather than a limit on computing.
The years this calendar spans.
Nanoseconds in a second, a minute, an hour and a day.
The smallest difference two moments can have.
A nanosecond rather than a microsecond: the clock here is finer, which is what a protocol timestamp and a benchmark both want.
@cron
Types
Cron
structA parsed expression: which values of each field it fires on.
Each field is a bit set, so asking whether a moment matches is six bit tests rather than a search. star_day and star_week are kept because the two fields interact — see [Cron::matches].
- seconds : Int64
- minutes : Int64
- hours : Int32
- days : Int32
- months : Int32
- weekdays : Int32
- star_day : Bool
- star_week : Bool
Whether m is a moment this expression fires on.
The day-of-month and day-of-week fields are or-ed when both are restricted, which is Vixie cron's rule and surprises everyone once: 0 0 13 * 5 is the thirteenth *or* any Friday, not Friday the thirteenth. When one of them is * they are and-ed, which is why 0 0 13 * * is only the thirteenth.
The first moment strictly after m that this expression fires on.
None when it never does. An expression can name a day that does not exist — 0 0 30 2 * is the thirtieth of February — so the search is bounded at four years, which is past any leap-year cycle a real schedule turns on.
Structural equality from Eq.
The negation of equal, from Eq.
The debug representation, from Debug.
Errors
Refused
suberrorWhy an expression was refused.
- Fields(got~ : Int32)
- Range(field~ : String, got~ : Int32, low~ : Int32, high~ : Int32)
- Malformed(String)
Structural equality from Eq.
The negation of equal, from Eq.
Writes the text form to a logger, from Show.
The debug representation, from Debug.
The text form, as a String, from Show.
Functions
An expression, in the five-field form crontab(5) defines or the six-field form that puts seconds in front.
┌───────────── second (0-59, six-field form only)
│ ┌───────────── minute (0-59)
│ │ ┌───────────── hour (0-23)
│ │ │ ┌───────────── day of month (1-31)
│ │ │ │ ┌───────────── month (1-12 or JAN-DEC)
│ │ │ │ │ ┌───────────── day of week (0-7 or SUN-SAT, both 0 and 7 being Sunday)
* * * * * *
Each field takes *, a number, a range a-b, a step */n or a-b/n, and a comma-separated list of those. ? reads as *, which is how a scheduler spells the day field it is not using.
The shorthands @yearly, @annually, @monthly, @weekly, @daily, @midnight and @hourly are the ones crontab(5) lists. @reboot is not here: it names an event rather than a time, and this package answers when something fires, not why.