A point-in-time event key represented as a single millisecond timestamp.
new Time(Date.now())Constructor
new Time(value: TimestampInput)
new Time(new Date())Creates a point-in-time key from a Date or millisecond timestamp.
Properties
Static methods
parsestatic
parse(value: string, options?: TimeZoneOptions): Time
Time.parse("2025-01-01T09:00", { timeZone: "Europe/Madrid" })Parses a strict ISO-like timestamp string into an absolute Time.
Methods
begin
begin(): number
time.begin()Returns the inclusive start of the key in milliseconds since epoch.
compare
compare(other: EventKey): number
time.compare(otherTime)Compares this key to another key for ordering.
contains
contains(other: TemporalLike): boolean
time.contains(Date.now())Returns true when this point fully contains the supplied temporal value.
duration
duration(): number
time.duration() // 0Returns the temporal duration of the key in milliseconds.
end
end(): number
time.end()Returns the inclusive end of the key in milliseconds since epoch.
equals
equals(other: EventKey): boolean
time.equals(otherTime)Returns true when the supplied key is the same Time.
intersection
intersection(other: TemporalLike): TimeRange | undefined
time.intersection(range)Returns the temporal intersection with the supplied value, if any.
isAfter
isAfter(other: TemporalLike): boolean
time.isAfter(otherTime)Returns true when this point begins strictly after the supplied temporal value ends.
isBefore
isBefore(other: TemporalLike): boolean
time.isBefore(otherTime)Returns true when this point ends strictly before the supplied temporal value begins.
overlaps
overlaps(other: TemporalLike): boolean
time.overlaps(range)Returns true when this point overlaps the supplied temporal value.
timeRange
timeRange(): TimeRange
time.timeRange()Returns this point as a zero-width TimeRange.
timestampMs
timestampMs(): number
time.timestampMs()Returns the key timestamp in milliseconds since epoch.
toDate
toDate(): Date
time.toDate()Returns a native Date for the key timestamp.
trim
trim(other: TemporalLike): Time | undefined
time.trim(range)Returns this key when it falls within the supplied temporal value, otherwise undefined.
type
type(): 'time'
time.type() // "time"Returns the key kind.
valueOf
valueOf(): number
Number(time)Returns the primitive millisecond timestamp for numeric coercion.