/*----------------------------------------------------------------------------
   Copyright 2012-2021, Microsoft Research, Daan Leijen

   Licensed under the Apache License, Version 2.0 ("The Licence"). You may not
   use this file except in compliance with the License. A copy of the License
   can be found in the LICENSE file at the root of this distribution.
----------------------------------------------------------------------------*/

/* 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 `:std/time/duration/duration`s and `:std/time/instant/instant`s instead.
*/
module std/time/timestampstd/time/timestamp

import std/num/float64std/num/float64
import std/num/ddoublestd/num/ddouble
import std/num/int32std/num/int32
import std/time/datestd/time/date

// Time spans are a time duration in some time scale represented as a `:ddouble`;
// this gives it very high precision and range to represent time very precisely.
// (see the [`instant`](std_time_instant.html) module)
pub alias timespanstd/time/timestamp/timespan: V = ddoublestd/num/ddouble/ddouble: V

// A zero-valued timespan.
pub val timespan0std/time/timestamp/timespan0: timespan : timespanstd/time/timestamp/timespan: V = zerostd/num/ddouble/zero: ddouble

pub fun int/timespanstd/time/timestamp/int/timespan: (seconds : int, frac : ? float64) -> timespan( secondsseconds: int : intstd/core/types/int: V, fracfrac: ? float64 : float64std/core/types/float64: V = 0.0literal: float64
hex64= 0x0p+0
)result: -> total timespan : timespanstd/time/timestamp/timespan: V if fracfrac: float64.is-zerostd/num/float64/is-zero: (d : float64) -> bool then ddoublestd/num/ddouble/int/ddouble: (i : int) -> ddouble(secondsseconds: int) else ddoublestd/num/ddouble/int/ddouble: (i : int) -> ddouble(secondsseconds: int) +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble ddoublestd/num/ddouble/float64/ddouble: (d : float64) -> ddouble(fracfrac: float64
) pub fun float64/timespanstd/time/timestamp/float64/timespan: (secs : float64) -> timespan( secssecs: float64 : float64std/core/types/float64: V )result: -> total timespan : timespanstd/time/timestamp/timespan: V ddoublestd/num/ddouble/float64/ddouble: (d : float64) -> ddouble(secssecs: float64) pub fun tuple64/timespanstd/time/timestamp/tuple64/timespan: (secs : float64, frac : float64) -> timespan( secssecs: float64 : float64std/core/types/float64: V, fracfrac: float64 : float64std/core/types/float64: V )result: -> total timespan : timespanstd/time/timestamp/timespan: V ddoublestd/num/ddouble/ddouble: (x : float64, y : float64) -> ddouble(secssecs: float64,fracfrac: float64) // Timespan from a `:ddouble`. Just for convenience as `:timespan` is an alias pub fun ddouble/timespanstd/time/timestamp/ddouble/timespan: (secs : ddouble) -> timespan( secssecs: ddouble : ddoublestd/num/ddouble/ddouble: V )result: -> total timespan : timespanstd/time/timestamp/timespan: V secssecs: ddouble // Divide using `div` to allow for different timespan representations pub fun divstd/time/timestamp/div: (x : timespan, y : timespan, prec : ? int) -> timespan( xx: timespan : timespanstd/time/timestamp/timespan: V, yy: timespan : timespanstd/time/timestamp/timespan: V, precprec: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
)result: -> total timespan : timespanstd/time/timestamp/timespan: V xx: timespan /std/num/ddouble/(/): (x : ddouble, y : ddouble) -> ddouble
yy: timespan // Seconds in a solar day, 86400. pub val isolar-secs-per-daystd/time/timestamp/isolar-secs-per-day: int = 86400literal: int
dec = 86400
hex32= 0x00015180
bit32= 0b00000000000000010101000110000000
pub val solar-secs-per-daystd/time/timestamp/solar-secs-per-day: timespan = isolar-secs-per-daystd/time/timestamp/isolar-secs-per-day: int.timespanstd/time/timestamp/int/timespan: (seconds : int, frac : ? float64) -> timespan /*---------------------------------------------------------------------------- Timestamps ----------------------------------------------------------------------------*/ /* 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](https://en.wikipedia.org/wiki/Unix_time). - One way is as a duration in TAI SI seconds but that would lead to many unnecessary conversions (and loss of precision), for example for unix timestamps that need adjustments for leap seconds. - To avoid conversions, it is better to represent as days plus the seconds into that day. However, that means that adding or subtracting seconds always needs normalization. - To make it easier to add/substract time spans, we can represent it as single timespan `since` where `days == floor(since / 86400)` and `seconds == since - days`. This is essentially the representation that Unix/Posic timestamps use too. - Finally, we add a separate `leap` seconds field to represent time in a leap step unambigiously (and also at any time during the day). The `leap` field is positive if this time is in a leap step. 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)" ``` The `leap` 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" ``` See `std/time/utc` for more information on leap seconds. */ abstract struct timestampstd/time/timestamp/timestamp: V( sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan : timespanstd/time/timestamp/timespan: V, // days+seconds since 2000-01-01 in the time scale // the extra leap seconds; always zero for any time scale except UTC based ones. leap32std/time/timestamp/timestamp/leap32: (timestamp : timestamp) -> int32 : int32std/core/types/int32: V ) pub fun leapstd/time/timestamp/leap: (t : timestamp) -> int( tt: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total int : intstd/core/types/int: V tt: timestamp.leap32std/time/timestamp/timestamp/leap32: (timestamp : timestamp) -> int32.intstd/num/int32/int: (i : int32) -> int // The time stamp at 2000-01-01 pub val timestamp0std/time/timestamp/timestamp0: timestamp : timestampstd/time/timestamp/timestamp: V = Timestampstd/time/timestamp/Timestamp: (since : timespan, leap32 : int32) -> timestamp(ddouble/zerostd/num/ddouble/zero: ddouble,int32/zerostd/num/int32/zero: int32) // Create a time stamp from a `:timespan` since 2000-01-01 and possible leap seconds. pub fun timestampstd/time/timestamp/timestamp: (t : timespan, leap : ? int) -> timestamp( tt: timespan : timespanstd/time/timestamp/timespan: V, leapleap: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
)result: -> total timestamp : timestampstd/time/timestamp/timestamp: V Timestampstd/time/timestamp/Timestamp: (since : timespan, leap32 : int32) -> timestamp(tt: timespan,leapleap: int.int32std/num/int32/int32: (i : int) -> int32
) // Create a time stamp from an integer timespan since 2000-01-01 and possible leap seconds. pub fun int/timestampstd/time/timestamp/int/timestamp: (t : int, frac : ? float64, leap : ? int) -> timestamp( tt: int : intstd/core/types/int: V, fracfrac: ? float64 : float64std/core/types/float64: V = 0.0literal: float64
hex64= 0x0p+0
, leapleap: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
)result: -> total timestamp : timestampstd/time/timestamp/timestamp: V timestampstd/time/timestamp/timestamp: (t : timespan, leap : ? int) -> timestamp(tt: int.ddoublestd/num/ddouble/int/ddouble: (i : int) -> ddouble +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble fracfrac: float64.ddoublestd/num/ddouble/float64/ddouble: (d : float64) -> ddouble,leapleap: int
) // Timestamp from days, seconds into the day and possible leap second. pub fun timestamp-daysstd/time/timestamp/timestamp-days: (days : int, secs : ? timespan, leap : ? int) -> timestamp( daysdays: int : intstd/core/types/int: V, secssecs: ? timespan : timespanstd/time/timestamp/timespan: V = timespan0std/time/timestamp/timespan0: timespan, leapleap: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
)result: -> total timestamp : timestampstd/time/timestamp/timestamp: V timestampstd/time/timestamp/timestamp: (t : timespan, leap : ? int) -> timestamp( (daysdays: int *std/core/int/(*): (int, int) -> int isolar-secs-per-daystd/time/timestamp/isolar-secs-per-day: int).timespanstd/time/timestamp/int/timespan: (seconds : int, frac : ? float64) -> timespan +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble secssecs: timespan, leapleap: int
) // Return days and seconds into the day, disregarding leap seconds. pub fun days-secondsstd/time/timestamp/days-seconds: (ts : timestamp) -> (int, ddouble)( tsts: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total (int, ddouble) : (std/core/types/tuple2: (V, V) -> Vintstd/core/types/int: V,ddoublestd/num/ddouble/ddouble: V) val secssecs: ddouble = tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan.floorstd/num/ddouble/floor: (x : ddouble) -> ddouble val fracfrac: ddouble = tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan -std/num/ddouble/(-): (x : ddouble, y : ddouble) -> ddouble secssecs: ddouble val (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)daysdays: int,dsecsdsecs: int)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) = divmodstd/core/int/divmod: (x : int, y : int) -> (int, int)(secssecs: ddouble.intstd/num/ddouble/int: (x : ddouble, nonfin : ? int) -> int, isolar-secs-per-daystd/time/timestamp/isolar-secs-per-day: int) (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)daysdays: int, dsecsdsecs: int.ddoublestd/num/ddouble/int/ddouble: (i : int) -> ddouble +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble fracfrac: ddouble)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) // Return days and clock into the day, handling possible leap seconds. pub fun days-clockstd/time/timestamp/days-clock: (ts : timestamp) -> (int, clock)( tsts: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total (int, clock) : (std/core/types/tuple2: (V, V) -> Vintstd/core/types/int: V,clockstd/time/date/clock: V) val (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)daysdays: int,secssecs: ddouble)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) = tsts: timestamp.days-secondsstd/time/timestamp/days-seconds: (ts : timestamp) -> (int, ddouble) (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)daysdays: int, clockstd/time/date/leap/clock: (seconds : ddouble, leap : int) -> clock(secssecs: ddouble,tsts: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int))std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) pub fun daysstd/time/timestamp/days: (ts : timestamp) -> int( tsts: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total int : intstd/core/types/int: V tsts: timestamp.days-secondsstd/time/timestamp/days-seconds: (ts : timestamp) -> (int, ddouble).fststd/core/types/tuple2/fst: (tuple2 : (int, ddouble)) -> int pub fun seconds-into-daystd/time/timestamp/seconds-into-day: (ts : timestamp) -> ddouble( tsts: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total ddouble : ddoublestd/num/ddouble/ddouble: V tsts: timestamp.days-secondsstd/time/timestamp/days-seconds: (ts : timestamp) -> (int, ddouble).sndstd/core/types/tuple2/snd: (tuple2 : (int, ddouble)) -> ddouble +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble tsts: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int.ddoublestd/num/ddouble/int/ddouble: (i : int) -> ddouble // The time span since 2000-01-01 including time inside a possible leap second. pub fun unsafe-timespan-withleapstd/time/timestamp/unsafe-timespan-withleap: (ts : timestamp) -> timespan( tsts: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total timespan : timespanstd/time/timestamp/timespan: V tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble tsts: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int.timespanstd/time/timestamp/int/timespan: (seconds : int, frac : ? float64) -> timespan // 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. pub fun timespan-noleapstd/time/timestamp/timespan-noleap: (ts : timestamp) -> timespan( tsts: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total timespan : timespanstd/time/timestamp/timespan: V tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan // Round a time stamp to a certain precision (`prec` is number of digits of the fraction of the second). pub fun round-to-precstd/time/timestamp/round-to-prec: (t : timestamp, prec : int) -> timestamp(tt: timestamp : timestampstd/time/timestamp/timestamp: V, precprec: int : intstd/core/types/int: V )result: -> total timestamp : timestampstd/time/timestamp/timestamp: V Timestampstd/time/timestamp/Timestamp: (since : timespan, leap32 : int32) -> timestamp(tt: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan.round-to-precstd/num/ddouble/round-to-prec: (x : ddouble, prec : int) -> ddouble(precprec: int), tt: timestamp.leap32std/time/timestamp/timestamp/leap32: (timestamp : timestamp) -> int32) // Add `leaps` leap seconds to the timestamp. pub fun add-leap-secondsstd/time/timestamp/add-leap-seconds: (ts : timestamp, leaps : timespan) -> timestamp( tsts: timestamp : timestampstd/time/timestamp/timestamp: V, leapsleaps: timespan : timespanstd/time/timestamp/timespan: V )result: -> total timestamp : timestampstd/time/timestamp/timestamp: V if !std/core/types/bool/(!): (b : bool) -> boolleapsleaps: timespan.is-posstd/num/ddouble/is-pos: (x : ddouble) -> bool then tsts: timestamp // + leaps // if negative, add as normal seconds elif leapsleaps: timespan <std/num/ddouble/(<): (x : ddouble, y : ddouble) -> bool 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
.timespanstd/time/timestamp/int/timespan: (seconds : int, frac : ? float64) -> timespan &&std/core/types/(&&): (x : bool, y : bool) -> bool tsts: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int.is-zerostd/core/int/is-zero: (x : int) -> bool then Timestampstd/time/timestamp/Timestamp: (since : timespan, leap32 : int32) -> timestamp( (tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan -std/num/ddouble/(-): (x : ddouble, y : ddouble) -> ddouble 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
.timespanstd/time/timestamp/int/timespan: (seconds : int, frac : ? float64) -> timespan) +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble leapsleaps: timespan, 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
.int32std/num/int32/int32: (i : int) -> int32) else Timestampstd/time/timestamp/Timestamp: (since : timespan, leap32 : int32) -> timestamp( tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble leapsleaps: timespan.fractionstd/num/ddouble/fraction: (x : ddouble) -> ddouble, tsts: timestamp.leap32std/time/timestamp/timestamp/leap32: (timestamp : timestamp) -> int32 +std/num/int32/(+): (x : int32, y : int32) -> int32 leapsleaps: timespan.truncatestd/num/ddouble/truncate: (x : ddouble) -> ddouble.intstd/num/ddouble/int: (x : ddouble, nonfin : ? int) -> int.int32std/num/int32/int32: (i : int) -> int32
) // Add `days` days to a timestamp pub fun add-daysstd/time/timestamp/add-days: (ts : timestamp, days : int) -> timestamp( tsts: timestamp : timestampstd/time/timestamp/timestamp: V, daysdays: int : intstd/core/types/int: V )result: -> total timestamp : timestampstd/time/timestamp/timestamp: V tsts: timestamp +std/time/timestamp/(+): (ts : timestamp, t : timespan) -> timestamp (daysdays: int *std/core/int/(*): (int, int) -> int isolar-secs-per-daystd/time/timestamp/isolar-secs-per-day: int).timespanstd/time/timestamp/int/timespan: (seconds : int, frac : ? float64) -> timespan // Compare two `:timestamp`s. pub fun cmpstd/time/timestamp/cmp: (i : timestamp, j : timestamp) -> order( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total order : orderstd/core/types/order: V match cmpstd/num/ddouble/cmp: (x : ddouble, y : ddouble) -> order(ii: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan,jj: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan) // cmp without leap-seconds first! Eqstd/core/types/Eq: order -> cmpstd/core/int/cmp: (x : int, y : int) -> order(ii: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int,jj: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int) ordord: order -> ordord: order pub fun (<)std/time/timestamp/(<): (i : timestamp, j : timestamp) -> bool( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total bool : boolstd/core/types/bool: V { cmpstd/time/timestamp/cmp: (i : timestamp, j : timestamp) -> order(ii: timestamp,jj: timestamp) ==std/core/order/(==): (x : order, y : order) -> bool Ltstd/core/types/Lt: order } pub fun (<=)std/time/timestamp/(<=): (i : timestamp, j : timestamp) -> bool( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total bool : boolstd/core/types/bool: V { cmpstd/time/timestamp/cmp: (i : timestamp, j : timestamp) -> order(ii: timestamp,jj: timestamp) !=std/core/order/(!=): (x : order, y : order) -> bool Gtstd/core/types/Gt: order } pub fun (>)std/time/timestamp/(>): (i : timestamp, j : timestamp) -> bool( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total bool : boolstd/core/types/bool: V { cmpstd/time/timestamp/cmp: (i : timestamp, j : timestamp) -> order(ii: timestamp,jj: timestamp) ==std/core/order/(==): (x : order, y : order) -> bool Gtstd/core/types/Gt: order } pub fun (>=)std/time/timestamp/(>=): (i : timestamp, j : timestamp) -> bool( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total bool : boolstd/core/types/bool: V { cmpstd/time/timestamp/cmp: (i : timestamp, j : timestamp) -> order(ii: timestamp,jj: timestamp) !=std/core/order/(!=): (x : order, y : order) -> bool Ltstd/core/types/Lt: order } pub fun (==)std/time/timestamp/(==): (i : timestamp, j : timestamp) -> bool( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total bool : boolstd/core/types/bool: V { cmpstd/time/timestamp/cmp: (i : timestamp, j : timestamp) -> order(ii: timestamp,jj: timestamp) ==std/core/order/(==): (x : order, y : order) -> bool Eqstd/core/types/Eq: order } pub fun (!=)std/time/timestamp/(!=): (i : timestamp, j : timestamp) -> bool( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total bool : boolstd/core/types/bool: V { cmpstd/time/timestamp/cmp: (i : timestamp, j : timestamp) -> order(ii: timestamp,jj: timestamp) !=std/core/order/(!=): (x : order, y : order) -> bool Eqstd/core/types/Eq: order } // The minimum of two timestamps. pub fun minstd/time/timestamp/min: (i : timestamp, j : timestamp) -> timestamp( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total timestamp : timestampstd/time/timestamp/timestamp: V if ii: timestamp <=std/time/timestamp/(<=): (i : timestamp, j : timestamp) -> bool jj: timestamp then ii: timestamp else jj: timestamp // The maximum of two timestamps. pub fun maxstd/time/timestamp/max: (i : timestamp, j : timestamp) -> timestamp( ii: timestamp : timestampstd/time/timestamp/timestamp: V, jj: timestamp : timestampstd/time/timestamp/timestamp: V )result: -> total timestamp : timestampstd/time/timestamp/timestamp: V if ii: timestamp >=std/time/timestamp/(>=): (i : timestamp, j : timestamp) -> bool jj: timestamp then ii: timestamp else jj: timestamp // Add a time span to a time stamp. pub fun (+)std/time/timestamp/(+): (ts : timestamp, t : timespan) -> timestamp( tsts: timestamp : timestampstd/time/timestamp/timestamp: V, tt: timespan : timespanstd/time/timestamp/timespan: V )result: -> total timestamp : timestampstd/time/timestamp/timestamp: V Timestampstd/time/timestamp/Timestamp: (since : timespan, leap32 : int32) -> timestamp(tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan +std/num/ddouble/(+): (x : ddouble, y : ddouble) -> ddouble tt: timespan, tsts: timestamp.leap32std/time/timestamp/timestamp/leap32: (timestamp : timestamp) -> int32) // Subtract a time span from a time stamp. pub fun (-)std/time/timestamp/(-): (ts : timestamp, t : timespan) -> timestamp( tsts: timestamp : timestampstd/time/timestamp/timestamp: V, tt: timespan : timespanstd/time/timestamp/timespan: V )result: -> total timestamp : timestampstd/time/timestamp/timestamp: V Timestampstd/time/timestamp/Timestamp: (since : timespan, leap32 : int32) -> timestamp(tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan -std/num/ddouble/(-): (x : ddouble, y : ddouble) -> ddouble tt: timespan, tsts: timestamp.leap32std/time/timestamp/timestamp/leap32: (timestamp : timestamp) -> int32) // Show a time stamp. pub fun ts-showstd/time/timestamp/ts-show: (ts : timestamp, max-prec : ? int, secs-width : ? int, unit : ? string) -> string( tsts: timestamp : timestampstd/time/timestamp/timestamp: V, max-precmax-prec: ? int : intstd/core/types/int: V = 9literal: int
dec = 9
hex8 = 0x09
bit8 = 0b00001001
, secs-widthsecs-width: ? int : intstd/core/types/int: V = 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
, unitunit: ? string : stringstd/core/types/string: V = ""literal: string
count= 0
)result: -> total string : stringstd/core/types/string: V val ll: string = if tsts: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int.is-zerostd/core/int/is-zero: (x : int) -> bool then ""literal: string
count= 0
else " (+"literal: string
count= 3
++std/core/types/(++): (x : string, y : string) -> string tsts: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int.showstd/core/int/show: (i : int) -> string ++std/core/types/(++): (x : string, y : string) -> string " leap)"literal: string
count= 6
tsts: timestamp.sincestd/time/timestamp/timestamp/since: (timestamp : timestamp) -> timespan.show-secondsstd/time/date/show-seconds: (secs : ddouble, max-prec : ? int, secs-width : ? int, unit : ? string) -> string(max-precmax-prec: int,secs-widthsecs-width: int,unitunit: string) ++std/core/types/(++): (x : string, y : string) -> string
ll: string // Show a day stamp pub fun ts-show-daysstd/time/timestamp/ts-show-days: (ts : timestamp, prec : ? int) -> string( tsts: timestamp : timestampstd/time/timestamp/timestamp: V, precprec: ? int : intstd/core/types/int: V = 9literal: int
dec = 9
hex8 = 0x09
bit8 = 0b00001001
)result: -> total string : stringstd/core/types/string: V val (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)daysdays: int,secssecs: ddouble)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) = tsts: timestamp.days-secondsstd/time/timestamp/days-seconds: (ts : timestamp) -> (int, ddouble) daysdays: int.showstd/core/int/show: (i : int) -> string ++std/core/types/(++): (x : string, y : string) -> string "d "literal: string
count= 2
++std/core/types/(++): (x : string, y : string) -> string ts-showstd/time/timestamp/ts-show: (ts : timestamp, max-prec : ? int, secs-width : ? int, unit : ? string) -> string(timestampstd/time/timestamp/timestamp: (t : timespan, leap : ? int) -> timestamp(secssecs: ddouble,tsts: timestamp.leapstd/time/timestamp/leap: (t : timestamp) -> int),precprec: int,unit="s"literal: string
count= 1
)