Skip to main content

Module time

Module time 

Source
Expand description

The small amount of calendar arithmetic a scheduler needs.

The framework has no date type: rustlavel-db deliberately leaves a timestamptz column as text so precision survives, and core has nothing richer than SystemTime. A cron schedule cannot be computed without real calendar maths, so this module carries the minimum — seconds since the Unix epoch in and out of a civil UTC date, and nothing else.

Everything the queue stores is epoch seconds rather than a timestamp column, for the same reason: an integer compares and sorts identically in every driver, and no part of the system has to agree on a text format.

The conversions are Howard Hinnant’s days_from_civil / civil_from_days, chosen because they are exact for every year in range and short enough to verify by reading.

Structs§

DateTime
A civil date and time in UTC.

Constants§

SECONDS_PER_DAY
Seconds in a day. Leap seconds do not exist in Unix time, so this is exact.

Functions§

from_unix
Split epoch seconds into a civil UTC date and time.
start_of_day
The start of the day containing seconds.
start_of_minute
The start of the minute containing seconds.
to_unix
Build epoch seconds from a civil UTC date and time.
unix_now
Now, in seconds since the epoch.