Low level time spans and time stamps.

These are unit-less and may not necessarily be in (TAI) SI seconds, and are used internally to do time scale conversions and calendar calculations. User code should use durations and instants instead.

alias timespanstd/time/timestamp/timespan: V = ddoublestd/num/ddouble/ddouble: V

Time spans are a time duration in some time scale represented as a ddoublestd/num/ddouble/ddouble: V; this gives it very high precision and range to represent time very precisely. (see the instant module).

type timestampstd/time/timestamp/timestamp: V

A time stamp denotes an instant in time since 2000-01-01 in some time scale. Time stamps also keep track of possible leap seconds for UTC based timescales. Unix/UTC seconds.

Here is the representation of a time in the leap second just before 2006-01-01:

time(2005,12,31,23,59,60,0.5).instant.timestamp.ts-show == "189388799.500 (+1 leap)"
time(2005,12,31,23,59,60,0.5).instant.timestamp.ts-show-days == "2191d 86399.500s (+1 leap)"
time(2005,12,31,23,59,60,0.5).instant.timestamp.ts-showstd/time/timestamp/ts-show: (ts : timestamp, max-prec : ? int, secs-width : ? int, unit : ? string) -> string == "189388799.500 (+1 leap)"
time(2005,12,31,23,59,60,0.5).instant.timestamp.ts-show-daysstd/time/timestamp/ts-show-days: (ts : timestamp, prec : ? int) -> string == "2191d 86399.500s (+1 leap)"

The leapstd/time/timestamp/leap: (t : timestamp) -> int field also lets us represent leap times that occurred at another time than the last second of the day:

time(1959,1,28,18,59,59,0.01).instant.timestamp.ts-show-days == "-14948d 68399.010s"
time(1959,1,28,18,59,60,0.01).instant.timestamp.ts-show-days == "-14948d 68399.010s (+1 leap)"
time(1959,1,28,19, 0, 0,0.01).instant.timestamp.ts-show-days == "-14948d 68400.010s"
time(1959,1,28,18,59,59,0.01).instant.timestamp.ts-show-daysstd/time/timestamp/ts-show-days: (ts : timestamp, prec : ? int) -> string == "-14948d 68399.010s"
time(1959,1,28,18,59,60,0.01).instant.timestamp.ts-show-daysstd/time/timestamp/ts-show-days: (ts : timestamp, prec : ? int) -> string == "-14948d 68399.010s (+1 leap)"
time(1959,1,28,19, 0, 0,0.01).instant.timestamp.ts-show-daysstd/time/timestamp/ts-show-days: (ts : timestamp, prec : ? int) -> string == "-14948d 68400.010s"

See utc for more information on leap seconds.

Create a time stamp from an integer timespan since 2000-01-01 and possible leap seconds.

Return days and clock into the day, handling possible leap seconds.

Return days and seconds into the day, disregarding leap seconds.

Round a time stamp to a certain precision (prec is number of digits of the fraction of the second).

The time span since 2000-01-01 for time scales that do not have leap seconds and where every day is 86400s. For time scales with leap seconds, this effectively ignores any leap seconds.

Create a time stamp from a timespanstd/time/timestamp/timespan: V since 2000-01-01 and possible leap seconds.

Timestamp from days, seconds into the day and possible leap second.

The time stamp at 2000-01-01.

The time span since 2000-01-01 including time inside a possible leap second.

fun ddouble/timespan( secs : ddoublestd/num/ddouble/ddouble: V ) : timespanstd/time/timestamp/timespan: V

Timespan from a ddoublestd/num/ddouble/ddouble: V. Just for convenience as timespanstd/time/timestamp/timespan: V is an alias.

fun float64/timespan( secs : float64std/core/types/float64: V ) : timespanstd/time/timestamp/timespan: V
fun int/timespan( seconds : intstd/core/types/int: V, frac : ? float64std/core/types/float64: V ) : timespanstd/time/timestamp/timespan: V
fun tuple64/timespan( secs : float64std/core/types/float64: V, frac : float64std/core/types/float64: V ) : timespanstd/time/timestamp/timespan: V
fun div( x : timespanstd/time/timestamp/timespan: V, y : timespanstd/time/timestamp/timespan: V, prec : ? intstd/core/types/int: V ) : timespanstd/time/timestamp/timespan: V

Divide using divstd/time/timestamp/div: (x : timespan, y : timespan, prec : ? int) -> timespan to allow for different timespan representations.

val isolar-secs-per-day: intstd/core/types/int: V

Seconds in a solar day, 86400.

val solar-secs-per-day: timespanstd/time/timestamp/timespan: V
val timespan0: timespanstd/time/timestamp/timespan: V

A zero-valued timespan.

private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/boolstd/core/bool, std/core/orderstd/core/order, std/core/charstd/core/char, std/core/intstd/core/int, std/core/vectorstd/core/vector, std/core/stringstd/core/string, std/core/sslicestd/core/sslice, std/core/liststd/core/list, std/core/maybestd/core/maybe, std/core/eitherstd/core/either, std/core/tuplestd/core/tuple, std/core/showstd/core/show, std/core/debugstd/core/debug, std/core/delayedstd/core/delayed, std/core/consolestd/core/console, std/corestd/core, std/num/float64std/num/float64, std/num/ddoublestd/num/ddouble, std/num/int32std/num/int32, std/time/datestd/time/date