Appearance
meos.js / DateSpan
Class: DateSpan
Defined in: core/types/collections/time/DateSpan.ts:28
A contiguous range of calendar dates.
Dates are represented as DateADT integers (days since 2000-01-01).
Example
ts
const s = DateSpan.fromString('[2020-01-01, 2020-12-31]');
console.log(s.lower()); // days since 2000-01-01
console.log(s.durationDays()); // 365
s.free();Extends
Constructors
Constructor
ts
new DateSpan(inner): DateSpan;Defined in: core/types/collections/base/Span.ts:45
Parameters
inner
number
Returns
DateSpan
Inherited from
Accessors
inner
Get Signature
ts
get inner(): number;Defined in: core/types/collections/base/Span.ts:57
Raw WASM heap pointer. Do not free this value directly; use free.
Returns
number
Inherited from
Methods
[dispose]()
ts
dispose: void;Defined in: core/types/collections/base/Span.ts:67
Implements the using resource-management protocol — calls free automatically.
Returns
void
Inherited from
asHexWKB()
ts
asHexWKB(variant?): string;Defined in: core/types/collections/base/Span.ts:90
Serialises this span to a hex-encoded WKB string.
Parameters
variant?
number = 4
WKB encoding variant (default 4 = Extended WKB).
Returns
string
Inherited from
contains()
ts
contains(other): boolean;Defined in: core/types/collections/base/Span.ts:149
true if this entirely contains other.
Parameters
other
this
Returns
boolean
Inherited from
copy()
ts
copy(): this;Defined in: core/types/collections/base/Span.ts:75
Returns a deep copy of this span. The caller is responsible for calling free on the returned copy.
Returns
this
Inherited from
distance()
ts
distance(other): number;Defined in: core/types/collections/time/DateSpan.ts:116
Returns the distance (gap) between this and other in days. Returns 0 if they overlap or are adjacent.
Parameters
other
this
Returns
number
Overrides
durationDays()
ts
durationDays(): number;Defined in: core/types/collections/time/DateSpan.ts:89
Returns the number of days between the lower and upper bounds (upper - lower).
Returns
number
eq()
ts
eq(other): boolean;Defined in: core/types/collections/base/Span.ts:233
true if this and other have identical bounds and inclusivity.
Parameters
other
this
Returns
boolean
Inherited from
free()
ts
free(): void;Defined in: core/types/collections/base/Span.ts:62
Releases the WASM-allocated memory. Must be called when the object is no longer needed.
Returns
void
Inherited from
ge()
ts
ge(other): boolean;Defined in: core/types/collections/base/Span.ts:258
true if this is greater than or equal to other in MEOS total ordering.
Parameters
other
this
Returns
boolean
Inherited from
gt()
ts
gt(other): boolean;Defined in: core/types/collections/base/Span.ts:253
true if this is strictly greater than other in MEOS total ordering.
Parameters
other
this
Returns
boolean
Inherited from
hash()
ts
hash(): number;Defined in: core/types/collections/base/Span.ts:121
32-bit integer hash of this span.
Returns
number
Inherited from
intersection()
ts
intersection(other): DateSpan | null;Defined in: core/types/collections/base/Span.ts:207
Returns the intersection of this and other, or null if they are disjoint. The caller is responsible for calling free on the result.
Parameters
other
this
Returns
DateSpan | null
Inherited from
isAdjacent()
ts
isAdjacent(other): boolean;Defined in: core/types/collections/time/DateSpan.ts:101
true if this and other touch at exactly one boundary date without overlapping. For example, [2020-01-01, 2020-06-01) is adjacent to [2020-06-01, 2020-12-31].
Parameters
other
this
Returns
boolean
Overrides
isAfter()
ts
isAfter(other): boolean;Defined in: core/types/collections/base/Span.ts:176
true if every point in this is strictly greater than every point in other (no overlap).
Parameters
other
this
Returns
boolean
Inherited from
isBefore()
ts
isBefore(other): boolean;Defined in: core/types/collections/base/Span.ts:163
true if every point in this is strictly less than every point in other (no overlap).
Parameters
other
this
Returns
boolean
Inherited from
isContainedIn()
ts
isContainedIn(other): boolean;Defined in: core/types/collections/base/Span.ts:144
true if this is entirely contained within other.
Parameters
other
this
Returns
boolean
Inherited from
isOverOrAfter()
ts
isOverOrAfter(other): boolean;Defined in: core/types/collections/base/Span.ts:184
true if this does not extend to the left of other (i.e. min(this) ≥ min(other)).
Parameters
other
this
Returns
boolean
Inherited from
isOverOrBefore()
ts
isOverOrBefore(other): boolean;Defined in: core/types/collections/base/Span.ts:171
true if this does not extend to the right of other (i.e. max(this) ≤ max(other)).
Parameters
other
this
Returns
boolean
Inherited from
le()
ts
le(other): boolean;Defined in: core/types/collections/base/Span.ts:248
true if this is less than or equal to other in MEOS total ordering.
Parameters
other
this
Returns
boolean
Inherited from
lower()
ts
lower(): number;Defined in: core/types/collections/time/DateSpan.ts:79
Returns the lower bound as days since 2000-01-01.
Returns
number
Overrides
lowerInc()
ts
lowerInc(): boolean;Defined in: core/types/collections/base/Span.ts:111
true if the lower bound is inclusive ([).
Returns
boolean
Inherited from
lt()
ts
lt(other): boolean;Defined in: core/types/collections/base/Span.ts:243
true if this is strictly less than other in MEOS total ordering.
Parameters
other
this
Returns
boolean
Inherited from
minus()
ts
minus(other): number;Defined in: core/types/collections/base/Span.ts:216
Returns the part of this that is not in other as a raw WASM pointer. The result may represent a SpanSet when the subtraction splits this span into two parts.
Parameters
other
this
Returns
number
Inherited from
ne()
ts
ne(other): boolean;Defined in: core/types/collections/base/Span.ts:238
true if this and other differ in at least one bound or inclusivity.
Parameters
other
this
Returns
boolean
Inherited from
overlaps()
ts
overlaps(other): boolean;Defined in: core/types/collections/base/Span.ts:154
true if this and other share at least one point.
Parameters
other
this
Returns
boolean
Inherited from
shiftScale()
ts
shiftScale(
shift,
width,
hasShift?,
hasWidth?): DateSpan;Defined in: core/types/collections/time/DateSpan.ts:139
Returns a new span shifted and/or scaled along the date axis.
Parameters
shift
number
Number of days to shift (ignored when hasShift is false).
width
number
New total width in days (ignored when hasWidth is false).
hasShift?
boolean = true
Set to false to skip shifting (default true).
hasWidth?
boolean = true
Set to false to skip scaling (default true).
Returns
DateSpan
toSpanSet()
ts
toSpanSet(): number;Defined in: core/types/collections/base/Span.ts:129
Wraps this span in a one-element SpanSet and returns the raw WASM pointer. Use the appropriate SpanSet constructor (e.g. new IntSpanSet(ptr)) to obtain a typed object.
Returns
number
Inherited from
toString()
ts
toString(): string;Defined in: core/types/collections/time/DateSpan.ts:74
Returns the WKT string representation (e.g. [2020-01-01, 2020-12-31]).
Returns
string
Overrides
toTsTzSpan()
ts
toTsTzSpan(): number;Defined in: core/types/collections/time/DateSpan.ts:128
Converts this span to a TsTzSpan (date bounds become midnight UTC) and returns the raw WASM pointer. Use new TsTzSpan(ptr) to obtain a typed object.
Returns
number
union()
ts
union(other): number;Defined in: core/types/collections/base/Span.ts:224
Returns the union of this and other as a raw WASM pointer. The spans do not need to be adjacent or overlapping.
Parameters
other
this
Returns
number
Inherited from
upper()
ts
upper(): number;Defined in: core/types/collections/time/DateSpan.ts:84
Returns the upper bound as days since 2000-01-01.
Returns
number
Overrides
upperInc()
ts
upperInc(): boolean;Defined in: core/types/collections/base/Span.ts:116
true if the upper bound is inclusive (]).
Returns
boolean
Inherited from
fromBounds()
ts
static fromBounds(
lower,
upper,
lowerInc?,
upperInc?): DateSpan;Defined in: core/types/collections/time/DateSpan.ts:52
Creates a DateSpan from explicit date bounds.
Parameters
lower
number
Lower bound as days since 2000-01-01.
upper
number
Upper bound as days since 2000-01-01.
lowerInc?
boolean = true
true for inclusive lower bound [ (default).
upperInc?
boolean = false
true for inclusive upper bound ] (default false).
Returns
DateSpan
fromHexWKB()
ts
static fromHexWKB(hexwkb): DateSpan;Defined in: core/types/collections/time/DateSpan.ts:65
Deserialises a DateSpan from a hex-encoded WKB string produced by asHexWKB.
Parameters
hexwkb
string
Hex-encoded WKB string.
Returns
DateSpan
fromString()
ts
static fromString(str): DateSpan;Defined in: core/types/collections/time/DateSpan.ts:41
Parses a DateSpan from its WKT string representation.
Parameters
str
string
WKT string, e.g. "[2020-01-01, 2020-12-31]".
Returns
DateSpan