module

Vex::TimeConverter

Constants

EMITTER = Time::Format.new("%FT%T.%N%:z")
EMITTER_UTC = Time::Format.new("%FT%T.%NZ")
LENIENT_PARSERS = [Time::Format.new("%FT%T.%N"), Time::Format.new("%FT%T"), Time::Format.new("%F %T.%N"), Time::Format.new("%F %T")]

Lenient fallbacks accommodate real-world emitters that drop the timezone or use a space separator. Canonical's Ubuntu Security Notice docs are one such producer ("2025-07-08 22:59:24.546301"). When the input has no zone we assume UTC, which matches the most common producer intent and lets these docs interoperate.

STRICT_PARSERS = [Time::Format.new("%FT%T.%N%:z"), Time::Format.new("%FT%T%:z"), Time::Format.new("%FT%T.%NZ"), Time::Format.new("%FT%TZ")]

RFC 3339 variants the spec mandates. These run first.

Instance methods

format(time : Time) : String

Emits Z for UTC instants (matching go-vex and the spec example), and the explicit offset like +09:00 otherwise. Both forms are valid RFC 3339.

Source
from_json(parser : JSON::PullParser) : Time
Source
parse(string : String) : Time
Source
to_json(value : Time, json : JSON::Builder) : Nil
Source