moondate — dates, times, instants, durations and cron expressions for MoonBit. The proleptic Gregorian calendar with the arithmetic that goes with it; RFC 3339, the four shapes TOML names, HTTP's IMF-fixdate and ASN.1's two time forms, read and written; and a cron package that answers when an expression fires next.
let stamp = @moondate.parse("2026-09-22T14:30:00+08:00")
stamp.epoch() // seconds since 1970, for a moment that names one
stamp.astimezone(Utc) // the same instant, read elsewhere
stamp.strftime("%Y-%m-%d %H:%M %Z") // written the way Python writes it
stamp.plus(@moondate.Span::new(days=3L))
@cron.parse("0 9 * * MON-FRI").next(stamp) // nine o'clock on the next weekday| What it is | Written | |
|---|---|---|
| Zoned | An instant. Has an epoch, can be read in another zone. | 2026-09-22T14:30:00Z |
| Plain | A wall clock. An alarm, an opening time. | 2026-09-22T14:30:00 |
| Day | A date with no time. | 2026-09-22 |
| Clock | A time with no date. | 14:30:00 |
| Form | Where it is used |
|---|---|
| RFC 3339 / ISO 8601 | TOML, JSON Schema's date-time, most of the wire |
| IMF-fixdate, RFC 850, asctime | HTTP's Date header (RFC 9110 §5.6.7) — all three read, only the first written |
| UTCTime, GeneralizedTime | ASN.1, so X.509 validity (ITU-T X.680 §47) |
| strftime / strptime | The % directives C89 defines and Python implements |
@cron.parse("*/15 9-17 * * MON-FRI") // every quarter hour in working hours
@cron.parse("@daily")
@cron.parse("30 2 1 * *").next(now) // half past two on the firstmoon add moonbitstack/moondate| %Y %y %m %d | year, two-digit year, month, day |
| %H %I %M %S %f | hour, twelve-hour, minute, second, microseconds |
| %p %j %a %A %b %B | AM/PM, day of year, day and month names |
| %z %Z | offset as +HHMM, and UTC |
| %G %V %u %w | ISO year, ISO week, ISO weekday, weekday from Sunday |
| %% | a per cent sign |
fn leap(year : Int) -> BoolInstall
Download zipmoondate — dates, times, instants, durations and cron expressions for MoonBit. The proleptic Gregorian calendar with the arithmetic that goes with it; RFC 3339, the four shapes TOML names, HTTP's IMF-fixdate and ASN.1's two time forms, read and written; and a cron package that answers when an expression fires next.