Skip to main content

Module clock

Module clock 

Source
Expand description

Dates and times without a date crate.

spar needs a moment in four shapes: a file stamp that sorts, a header line a person reads, the RFC 3339 form GitHub returns so a recorded time compares with a comment’s created_at as a string, and the HTTP date form a conditional request sends back. The days to civil arithmetic is Howard Hinnant’s, valid for any date this will ever see.

Functions§

date_line
2026-09-12 14:03 UTC, for the header a person reads.
file_stamp
yyyymmdd-hhmmss in UTC, for a file name that sorts by when it was made.
http_date
Tue, 20 Oct 2026 10:00:00 GMT, the shape a Last-Modified header takes and an If-Modified-Since header sends back.
now_secs
parse_rfc3339
2026-10-20T18:04:05Z back to seconds. A fractional second is accepted and dropped; anything else that is not that shape, or is before 1970, is None.
rfc3339
2026-10-20T18:04:05Z, the shape GitHub returns, so a time spar recorded and a time GitHub reports compare as strings.