Skip to main content

Module dates

Module dates 

Source
Expand description

Date helpers for the read path.

Things stores user-facing dates (startDate, deadline) as bit-packed integers:

  bit  27                              0
       YYYYYYYYYYYY MMMM DDDDD 0000000
       ↑ 12 bits    ↑ 4   ↑ 5   ↑ 7 bits padding

0 means “no date” (Things never writes 1970-00-00). Things stores row-modification timestamps (creationDate, userModificationDate, stopDate) separately as REAL Unix seconds — those go through unix_to_iso over in queries.rs, not here.

Functions§

decode_things_date
Decode a Things packed date into an ISO YYYY-MM-DD string. Returns None for 0 and for out-of-range / malformed values so a future schema change can’t surface garbage to callers.
pack_things_date
Pack a (year, month, day) triple back into Things’ format. Used by query helpers that need to compare against today or user-supplied date bounds without round-tripping through ISO strings.
parse_iso_date
Parse YYYY-MM-DD into (y, m, d). Returns None on any deviation from the strict 10-character ISO date form so caller validation is straightforward.
today_packed_utc
Today’s date (UTC), packed for direct comparison against Things’ startDate / deadline columns.
ymd_to_unix_utc
(year, month, day) → Unix epoch seconds (00:00 UTC of that date). Inverse of core::backup::unix_to_ymdhms rounded to whole days. Used by things_list_logbook’s from/to filters which compare against stopDate (REAL Unix seconds).