Vibescript Showcase

Event timestamps

Emit RFC3339 timestamps at whole-second and sub-second precision with iso8601 and xmlschema.

Showcase
Source showcase/time/timestamps.vibe
# title: Event timestamps
# category: Vibescript Showcase
# difficulty: Showcase
# summary: Emit RFC3339 timestamps at whole-second and sub-second precision with iso8601 and xmlschema.
# description: 1.0 gives Time the Ruby RFC3339 aliases and optional fractional precision, and time-minus-seconds math, so event logs and audit trails serialize consistently.
# tags: time, timestamps, serialization
# vibe: 0.4

def stamps(base: time) -> hash
  {
    iso: base.iso8601,
    xml: base.xmlschema,
    millis: base.iso8601(3),
    one_minute_later: (base + 60).iso8601
  }
end

def run
  base = Time.utc(2024, 1, 1, 9, 30, 0)

  {
    stamps: stamps(base),
    epoch: Time.utc(1970, 1, 1).iso8601,
    year_start: Time.utc(2024).iso8601
  }
end
Output
Press run to execute run from this example.