Date, Time, Clock, Lapses - CPULL/Dflat GitHub Wiki

Dates, Times, Clocks, and Lapses

Date

Used to represent a point in time, uses the same Unix timestamp format and base epoch. It is based in milliseconds.

  • 64-bit signed, milliseconds since 1 Jan 1970 UTC.
  • A null date is represented by the minimum i64 value.
  • A date does not have information about timezones
  • It can be formatted in a similar way of C#, full details are in Strings / Formatting Dates
date today = Root.Now()

Date Formatting:

  • Uses C# custom pattern letters: d, f, F, g, h, H, k, m, M, s, t, y, z.
  • Additions: w (week), q (quarter), i (ISO week), r (ISO year), e (day of year, 3 wide), j (day of week).
  • A doubled letter pads with a space.
  • Alignment: a<20, a^20, a>20; no truncation.
  • Locale names and first day of week are designated for later.
Print(Root.Now().toStr("yyyy-MM-dd HH:mm")) -> 2028-12-03 21:33

Clock

  • u64 monotonic counter, 0.1 ns, obtained from Root.GetClock().
  • Used for intervals only.
  • GetClock() never returns 0.
  • Null clock is represented by 0.
clock start = Root.GetClock()

Lapse

  • Difference between two dates or two clocks, signed 64-bit.
  • Raw value = value * 8 + code.
  • Code values (bits 2-1-0):
    • 000: null
    • 010: date lapse, ms (range: +-36 million years)
    • 011: clock lapse, 0.1 ns (range: +-3.6 years)
    • 100: year lapse (range: beyond +-36M years)
    • 111: clock lapse overflow
  • Operations: date - date -> date lapse; clock - clock -> clock lapse; date - clock -> date lapse; .
  • Mixed units convert to date lapse, rounding away from zero, and null propagates.
  • Lapses format as numbers in their own unit.