Construct a new span.
Optional
Readonly
endExclusive ending time.
Optional
Readonly
modeThe relative mode. If undefined the span is absolute.
Optional
Readonly
startInclusive starting time.
Readonly
timezoneThe 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: DateStatic
fromCreate 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.
Generated using TypeDoc
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 toLuxonInterval and toMomentRange.