temporal
Canonical Import
(local temporal (require :temporal))Source Files
assets/lua/temporal.fnlassets/lua/temporal/standard.fnlassets/lua/temporal/period.fnlassets/lua/temporal/interval.fnlassets/lua/temporal/repeating-interval.fnlassets/lua/temporal/pattern.fnlassets/lua/temporal/recurrence.fnlassets/lua/temporal/expression.fnlassets/lua/temporal/natural.fnlsrc/lua_temporal_core.cpp
What It Provides
temporal is the high-level Fennel date/time toolkit. It wraps temporal-core with helpers for ISO parsing and formatting, calendar periods, intervals, repeating intervals, patterns, recurrence rules, simple natural-language expressions, and expression resolution.
API Summary
- Core groups forwarded from
temporal-core:duration,instant,plain-date-time,zoned-date-time,clock, andtzdb. standard:parse-instant(text),format-instant(instant),parse-plain-date-time(text),format-plain-date-time(plain),parse-zoned-date-time(text),format-zoned-date-time(zdt).period:from(parts),parse(text),format(period),negate(period),add-to-plain-date-time(plain period),subtract-from-plain-date-time(plain period).interval:from(options),parse(text options),format(interval),duration(interval),contains(interval value),shift(interval duration).repeating-interval:from(options),parse(text options),format(repeating),occurrences(repeating options).pattern:compile(pattern-text),parse(compiled text opts),format(compiled value).recurrence:from(options),parse-rrule(text),to-rrule(rule),occurrences(rule dtstart options).natural:parse(input)for supported phrases such astoday,tomorrow, relative day/week forms,next <weekday>, andevery <weekday>.expression:context(options)andresolve(expr ctx)for resolving natural expression results against a reference time.
Examples
(local temporal (require :temporal))
(local start (temporal.standard.parse-plain-date-time "2026-09-28T09:00:00"))
(local period (temporal.period.parse "P1W"))
(local end (temporal.period.add-to-plain-date-time start period))
(local meeting (temporal.interval.from {:type :plain-date-time
:start start
:end end}))
(print (temporal.interval.format meeting))
(print (temporal.period.format period))(local temporal (require :temporal))
(local rule (temporal.recurrence.from {:freq :weekly :count 3 :by-day [:mo]}))
(each [_ occurrence (ipairs (temporal.recurrence.occurrences rule
(temporal.standard.parse-plain-date-time "2026-09-28T09:00:00")
{}))]
(print (occurrence:to-string)))Errors and Platform Notes
Validation failures raise Lua errors with temporal-specific messages. Calendar period fields must be finite safe integers and may not mix positive and negative signs. Interval parsing requires an explicit :type option (:instant or :plain-date-time), and repeating intervals require either a finite count or an expansion limit. Time-zone behavior depends on the native tzdb available through temporal-core.
Related Modules
temporal-corefor native temporal objects and clocks.jsonandjson-utilsfor serializing temporal strings in persisted data.
Aliases and Search Terms
Search terms: date, time, datetime, duration, instant, time zone, tzdb, period, interval, recurrence, RRULE, natural date, calendar.
