Construct a new span.
Optional ReadonlyendExclusive ending time.
Optional ReadonlymodeThe relative mode. If undefined the span is absolute.
Optional ReadonlystartInclusive starting time.
ReadonlytimezoneThe timezone to use.
A JSON representation of a span.
Convert the span to a Luxon interval.
The haystack-core has zero runtime dependencies and supports web, node and deno environments.
However vanilla JavaScript lacks support for various calendar functions required to
make HSpan useful.
Warning: at the time of writing, the first day of the week does not vary between locales with Luxon.
import { DateTime, Interval } from 'luxon'
...
const interval = new HSpan({ mode: SpanMode.today })
.toLuxonInterval({ DateTime, Interval })
Optional_now: DateA luxon interval.
Convert the span to a moment range.
import * as Moment from 'moment-timezone'
import { extendMoment } from 'moment-range'
const moment = extendMoment(Moment)
...
const range = new HSpan({ mode: SpanMode.today })
.toMomentRange(moment)
Optional_now: DateStaticfromCreate a span from a encoded string or undefined if it can't be decoded.
Decode from string format:
SpanMode mode nameThe string to decode.
The decoded span or undefined.
Models a range of time using an inclusive starting timestamp and exclusive ending timestamp.
Please note, due to the lack of date time support in vanilla JavaScript, this implementation relies on using a third party library with proper timezone and locale support. See HSpan.toLuxonInterval and HSpan.toMomentRange.