Functional Weave
Code in Rust

time.iso-to-unix@1.0.0

README.md

1,321 bytes · view raw

# time.iso-to-unix

`isoToUnix("2009-02-13T23:31:30Z")` is `1234567890`, and
`isoToUnix("2026-09-26T13:00:00+01:00")` is the same instant as
`2026-09-26T12:00:00Z`. It reads the timestamps `time.unix-to-iso` writes,
and the ones other systems send, so that times can be compared as integers.

The accepted form is RFC 3339's `date-time`: `YYYY-MM-DD`, `T`, `HH:MM:SS`, an
optional fraction (`.5`, `.123456`), and a zone of `Z` or `+HH:MM` / `-HH:MM`.
RFC 3339 lets `T` and `Z` be lowercase, so they may be. A time with no zone is
refused, because the same wall-clock time is a different instant in every
zone and guessing one is how an hour goes missing twice a year.

A fraction is dropped, so `.999` still belongs to the second it started in
(Unix time floors). Seconds run 00-59: RFC 3339 allows `:60` for a leap
second, but Unix time has no number for it, so it is refused rather than
silently moved. Hours 00-23 (`24:00:00` is refused), offsets up to 23:59.

The date itself is checked by `dates.add-days`, so `2026-02-30` is refused
with its message (`is not a real calendar date`), and years run 0001 to
9999. No spaces, no week or ordinal dates, no missing seconds; ASCII digits
only.

Source: RFC 3339, Date and Time on the Internet: Timestamps, section 5.6
(https://www.rfc-editor.org/rfc/rfc3339#section-5.6).