Skip to main content

Module datetime

Module datetime 

Source
Expand description

Pure-arithmetic datetime manipulation (epoch-based, no system clock). DateTime support for CJC.

Design decisions:

  • Epoch millis (i64), UTC only — deterministic, no timezone ambiguity
  • datetime_now() is NONDET (uses system clock)
  • All other operations are pure arithmetic on epoch millis
  • Leap year handling for year/month/day extraction

Functions§

datetime_add_millis
Add milliseconds to a datetime.
datetime_day
Extract the day of month (1-31) from epoch millis.
datetime_diff
Difference between two datetimes in milliseconds.
datetime_format
Format a datetime as ISO 8601 UTC string: YYYY-MM-DDTHH:MM:SSZ
datetime_from_epoch
Create a datetime from epoch milliseconds (identity, but validates type).
datetime_from_parts
Create a datetime from year, month, day, hour, minute, second components. All components are 1-based for month/day.
datetime_hour
Extract the hour (0-23) from epoch millis.
datetime_minute
Extract the minute (0-59) from epoch millis.
datetime_month
Extract the month (1-12) from epoch millis.
datetime_now
Returns current UTC time as epoch milliseconds. This is NONDET — the only nondeterministic datetime operation.
datetime_second
Extract the second (0-59) from epoch millis.
datetime_year
Extract the year from epoch millis.
days_in_month
Return the number of days in the given month (1-12) of the given year.