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
Date.make(String) => Date
Date.make(Number, Number, Number) => Date
Date.make(Number) => Date
d1 = Date.make("2020-05-12") d2 = Date.make(2020, 5, 10) d3 = Date.make(2020.5)
Conversions
fromUnixTime
Date.fromUnixTime(Number) => Date
Date.fromUnixTime(1589222400)
toUnixTime
Date.toUnixTime(Date) => Number
Date.toUnixTime(Date.make(2020, 5, 12))
Algebra
subtract
infix: -
Namespace optional
Date.subtract(Date, Date) => Duration
subtract
infix: -
Namespace optional
Date.subtract(Date, Date) => Duration
add
infix: +
Namespace optional
Date.add(Date, Duration) => Date
Date.add(Duration, Date) => Date
Date.make(2020, 5, 12) + 20years
Comparison
smaller
infix: <
Namespace optional
Date.smaller(Date, Date) => Bool
larger
infix: >
Namespace optional
Date.larger(Date, Date) => Bool
smallerEq
infix: <=
Namespace optional
Date.smallerEq(Date, Date) => Bool
largerEq
infix: >=
Namespace optional
Date.largerEq(Date, Date) => Bool
Other
rangeDomain
Date.rangeDomain(Date, Date) => Domain
Date.rangeDomain(Date(2000), Date(2010))