Squiggle logoSquiggle
API

Date

Dates are a simple date time type.

Dates are stored as milliseconds since the epoch. They are immutable, and all functions that modify dates return a new date. Used with Duration values.

Dates can be useful for modeling values that change over time. Below is a simple example of a function that returns a normal distribution that changes over time, based on the number of years passed since 2020.

Constructors

make

Signatures
Date.make(String) => Date
Date.make(Number, Number, Number) => Date
Date.make(Number) => Date
Examples
d1 = Date.make("2020-05-12")
d2 = Date.make(2020, 5, 10)
d3 = Date.make(2020.5)

Conversions

fromUnixTime

Signatures
Date.fromUnixTime(Number) => Date
Examples
Date.fromUnixTime(1589222400)

toUnixTime

Signatures
Date.toUnixTime(Date) => Number
Examples
Date.toUnixTime(Date.make(2020, 5, 12))

Algebra

subtract

infix: -
Namespace optional
Signatures
Date.subtract(Date, Date) => Duration
Examples

subtract

infix: -
Namespace optional
Signatures
Date.subtract(Date, Date) => Duration
Examples

add

infix: +
Namespace optional
Signatures
Date.add(Date, Duration) => Date
Date.add(Duration, Date) => Date
Examples
Date.make(2020, 5, 12) + 20years

Comparison

smaller

infix: <
Namespace optional
Signatures
Date.smaller(Date, Date) => Bool

larger

infix: >
Namespace optional
Signatures
Date.larger(Date, Date) => Bool

smallerEq

infix: <=
Namespace optional
Signatures
Date.smallerEq(Date, Date) => Bool

largerEq

infix: >=
Namespace optional
Signatures
Date.largerEq(Date, Date) => Bool

Other

rangeDomain

Signatures
Date.rangeDomain(Date, Date) => Domain
Examples
Date.rangeDomain(Date(2000), Date(2010))

On this page