cl-date-kit¶
A dependency-free, SBCL-only date and time library.
Common Lisp has no standard date/time library beyond get-universal-time
and decode-universal-time, which cover neither time zones nor sub-second
precision. This project follows nerima-lisp's coding
standard:
target SBCL only, and spend the effort a general-purpose date library would
spend on portability on getting the genuinely hard parts -- the IANA time
zone database and daylight-saving disambiguation -- right instead.
Layers¶
cl-date-kit is organized as a serially loaded implementation stack; each layer is built only on the ones below it:
- Duration (
src/duration.lisp) -- an exact elapsed time (seconds + nanoseconds). java.time'sDuration, Rust'sDuration, Go'stime.Duration. - Period (
src/period.lisp) -- a calendar-based years/months/days delta. java.time'sPeriod. - LocalDate / Month / YearMonth / MonthDay / Year / LocalTime / LocalDateTime (
src/local-date.lisp,src/local-date-arithmetic.lisp,src/local-date-week.lisp,src/month.lisp,src/year-month.lisp,src/month-day.lisp,src/year.lisp,src/local-time.lisp,src/local-date-time.lisp) -- calendar date, ISO month, month-granularity, annual month/day, calendar year, wall-clock time, and their combinations, with no time zone attached. java.time'sLocalDate/LocalTime/LocalDateTime, Temporal'sPlainDate/PlainTime/PlainDateTime. - Instant (
src/instant.lisp) -- an absolute point on the UTC timeline. java.time'sInstant. - Interval (
src/interval.lisp) -- a half-open[start, end)range of absoluteInstantvalues, with overlap, intersection, span, and gap operations. - Clock (
src/clock.lisp) -- a boundary protocol for where "now" comes from, so tests can inject a fixed instant. java.time'sClock. - TZif (
src/tzif.lisp) -- a from-scratch reader for the IANA time zone database's on-disk binary format (RFC 8536). - Zone (
src/zone.lisp,src/zone-version.lisp,src/zone-local.lisp) --ZONE-OFFSET(a fixed UTC offset) andTIME-ZONE(an IANA zone backed by TZif's parsed rules).zone.lispowns zone data and instant-time lookup,zone-version.lispowns IANA tzdata release-version parsing, andzone-local.lispconverts local fields and resolves a wall-clockLOCAL-DATE-TIMEto one, zero, or two offsets depending on whether it falls in a daylight-saving gap or overlap. - ZonedDateTime (
src/zoned-date-time.lisp) -- aLOCAL-DATE-TIMEpaired with a resolvedZONE-OFFSET: the "real-world timestamp" type. - OffsetDateTime (
src/offset-date-time.lisp) -- aLOCAL-DATE-TIMEwith a fixed numeric offset, suited to RFC 3339 timestamps that have no IANA region identity. - OffsetTime (
src/offset-time.lisp) -- aLOCAL-TIMEwith a fixed numeric offset, for offset-qualified times that intentionally omit a date. - ISO8601 (
src/iso8601-date.lisp,src/iso8601.lisp) -- ISO-8601/RFC-3339 formatting and parsing for every type above, including calendar, ordinal, and ISO week dates.
See Core concepts for how they fit together and Architecture for the implementation decisions behind the TZif parser and daylight-saving disambiguation.