std/time/time▲toc

Time represents instants as human readable calendar time.

A timestd/time/time/time: V represents an instantstd/time/instant/instant: V in time in a given calendarstd/time/calendar/calendar: V and timezonestd/time/calendar/timezone: V as a “human” calendar time. Months, days etc. are always 1-based.

type timestd/time/time/time: V

Represents an instant in time for a certain calendar and timezone.

Add an SI second durationstd/time/duration/duration: V to a time.
(time(2015,12,31,23,59,59,0.5) + duration(1)).show == "2016-01-01T00:00:00.500Z"
(time(2016,12,31,23,59,59,0.5) + duration(1)).show == "2016-12-31T23:59:60.500Z"   (into a leap second).

Subtract an SI second durationstd/time/duration/duration: V from a time.
(time(2016,1,1,0,0,0,0.5) - duration(1)).show == "2015-12-31T23:59:59.500Z"
(time(2017,1,1,0,0,0,0.5) - duration(1)).show == "2016-12-31T23:59:60.500Z"   (into a leap second).

Automatically generated. Retrieves the calendar constructor field of the timestd/time/time/time: V type.

Automatically generated. Retrieves the clock constructor field of the timestd/time/time/time: V type.

Automatically generated. Retrieves the date constructor field of the timestd/time/time/time: V type.

Automatically generated. Retrieves the instant constructor field of the timestd/time/time/time: V type.

Convert a timestd/time/time/time: V t to a new timestd/time/time/time: V value in a potentially different timezone tz (=t.timezone by default) and calendar (=t.calendar by default).

Automatically generated. Retrieves the timezone constructor field of the timestd/time/time/time: V type.

Automatically generated. Retrieves the tzabbrv constructor field of the timestd/time/time/time: V type.

Automatically generated. Retrieves the tzdelta constructor field of the timestd/time/time/time: V type.

Return the exact SI second duration between to times.
(time(2016,1,1,0,0,0,0.5) - time(2015,12,31,23,59,59)).show == "1.5s"
(time(2017,1,1,0,0,0,0.5) - time(2016,12,31,23,59,59)).show == "2.5s"   (over a leap second)
(time(2017,1,1,0,0,0,0.5) - time(2017,1,1,2,59,59,tz=tz-fixedstd/time/calendar/tz-fixed: (hours : int, mins : ? int, name : ? string, abbrv : ? string, hourwidth : ? int) -> timezone(3)).show == "2.5s"   (GMT+3, and over a leap second).

Add a clock (hours, minutes, seconds) to a time. Takes leap years, leap seconds, etc. into account.

Add a date (years, months, days) and optional clock to a time. Takes leap years, leap seconds, etc. into account.

Add a specified number of days to a calendar time. Takes leap years etc. into account.
time(2016,12,31,12).add-days(1).show == "2017-01-01T12:00:00Z"   (over a leap second)
time(1582,10,4,cal=cal-jg).add-days(1).show == "1582-10-15T00:00:00Z JG"   (transition from Julian (cal-julian) to Gregorian (cal-gregorianstd/time/calendar/cal-gregorian: calendar) calendar).

Add a specified number of months to a calendar time.

Add a specified number of weeks to a calendar time.

Add a specified number of years to a calendar time.

Compare two timestd/time/time/time: Vs. Compares the actual instants in time and can thus compare across calendars and timezones.
time(2001,7,2,tz=tz-fixedstd/time/calendar/tz-fixed: (hours : int, mins : ? int, name : ? string, abbrv : ? string, hourwidth : ? int) -> timezone("GMT+1",duration(3600))) > time(2001,7,1,23,30,0)   (Falsestd/core/types/False: bool!).

Return the day of the month of a timestd/time/time/time: V. (starting at 1).

Return the day of the year of time t (starting at 1).

Return the total days in the month of time t.

Return the total days in the year of time t.

Return the days between two times. Uses the calendar and timezone of the first time t1 to determine the date of t2.

days-until( time(2000,1,1), time(2000,1,1) ) == 0
days-until( time(2000,1,1), time(2000,1,2) ) == 1
days-until( time(2000,1,1), time(2000,1,2,tz=tz-fixed(1)) ) == 0
days-until( time(2000,1,1), time(2000,3,1) ) == 60
days-until( time(2000,2,1), time(2000,1,1) ) == -1
days-until( time(2000,1,1), time(2000,1,1) ) == 0
days-until( time(2000,1,1), time(2000,1,2) ) == 1
days-until( time(2000,1,1), time(2000,1,2,tz=tz-fixedstd/time/calendar/tz-fixed: (hours : int, mins : ? int, name : ? string, abbrv : ? string, hourwidth : ? int) -> timezone(1)) ) == 0
days-until( time(2000,1,1), time(2000,3,1) ) == 60
days-until( time(2000,2,1), time(2000,1,1) ) == -1
.

Return the Julian date (JD) number for a given timestd/time/time/time: V t. This interprets the Julian date in the calendar of t with the timezone of t applied.
time(-4713,11,24,12,cal=cal-tt).jd == "0"
time(1972,1,2,tz=tz-fixedstd/time/calendar/tz-fixed: (hours : int, mins : ? int, name : ? string, abbrv : ? string, hourwidth : ? int) -> timezone(1)).jd == "2441318.5"
time(1972,1,2,tz=tz-fixedstd/time/calendar/tz-fixed: (hours : int, mins : ? int, name : ? string, abbrv : ? string, hourwidth : ? int) -> timezone(1)).instant.jd(ts-tistd/time/utc/ts-ti: timescale).show(9) == "2441318.458333333"

Takes leap seconds into account when calculating the fraction of the day, see mjd for examples.

Return the last week day of the month of time t.
time(2016,10,10).last-weekday-of-monthstd/time/time/last-weekday-of-month: (t : time, wd : weekday) -> time(Sunstd/time/date/Sun: weekday).date   (2016-10-30, Last Sunday of October 2016).

Convert a timestd/time/time/time: V t to a new timestd/time/time/time: V value in the local time zone in an optional calendar (=t.calendar by default).

The maximum of two times (as by their actual instant in time).

The minimum of two times (as by their actual instant in time).

Return the modified Julian date (MJD) number for a given timestd/time/time/time: V. This interprets the Modified Julian Date in the calendar system of t with the timezone applied.
time(1972,1,2,tz=tz-fixedstd/time/calendar/tz-fixed: (hours : int, mins : ? int, name : ? string, abbrv : ? string, hourwidth : ? int) -> timezone(1)).mjd == "41318"
time(1972,1,2,tz=tz-fixedstd/time/calendar/tz-fixed: (hours : int, mins : ? int, name : ? string, abbrv : ? string, hourwidth : ? int) -> timezone(1)).instant.mjd(ts-utc).show == "41317.958333335"   (one hour earlier)

Also takes leap seconds into account:
time(2015,12,31,12,0,0).mjd.show == "57387.5"   (exactly mid-day)
time(2016,12,31,12,0,0).mjd.show(9) == "57753.499994213"   (this day has a leap second, so it is just before the real middle of the day)
time(2016,12,31,12,0,0,0.5).mjd.show == "57753.5"   (real middle of the day).

Return the month of a timestd/time/time/time: V. (starting at 1).

Return the total months in the year of time t. For Gregorian calendars this is always 12 but some calendars have a varying number of months per year.

Return the nth week day following (and including) time t. Use n = 1 for the first week day wd following t; Use 0 for the last occurence of week day wd before t.
time(2016,10,10).nth-weekdaystd/time/time/nth-weekday: (t : time, n : int, wd : weekday) -> time(1,Sunstd/time/date/Sun: weekday)   (2016-10-13, first Sunday following October 10, 2016) time(2016,11,16).start-of-monthstd/time/time/start-of-month: (t : time) -> time.nth-weekdaystd/time/time/nth-weekday: (t : time, n : int, wd : weekday) -> time(0,Wedstd/time/date/Wed: weekday)   (2016-10-26, the last Wednesday before 2016-11-01).

Return the nth week day since the beginning of the month of time t.
time(2016,10,10).nth-weekday-of-monthstd/time/time/nth-weekday-of-month: (t : time, n : int, wd : weekday) -> time(2,Sunstd/time/date/Sun: weekday).date   (2016-10-09, Second Sunday of October 2016)
time(2016,10,10).nth-weekday-of-monthstd/time/time/nth-weekday-of-month: (t : time, n : int, wd : weekday) -> time(60,Sunstd/time/date/Sun: weekday).date   (2017-11-19, 60th Sunday since October 1, 2016).

Round a time to a specified second precision.

Return the time at the start of the day of time t.

Return the time at the start of the month of time t.

Return the time at the start of the week (Monday) of time t.

Return the time at the start of the year of time t.

Return the timestd/time/time/time: V value for a given date and clock in a timezone tz (=tz-utcstd/time/calendar/tz-utc: timezone by default) interpreted by calendar cal (=cal-isostd/time/calendar/cal-iso: calendar).

The month, day, hour, minutes may be outside their usual ranges and will be normalized during the conversion. For example, January 33 converts to February 2. This makes it very easy to add- or subtract days or months to an existing time.

When the seconds or fraction of seconds frac add up over 60 though, those extra seconds are interpreted as leap seconds.

Due to timezone transitions, or leap seconds, it is possible to specify dates that never happened (as it was skipped by a timezone change), or ambigious times (as a timezone springs back). In such cases, the time is always interpreted in the earlier timezone.

Return the weekday of a given time t.

fun show-tzdelta( delta : durationstd/time/duration/duration: V, utc : ? stringstd/core/types/string: V, hmsep : ? stringstd/core/types/string: V, hrwidth : ? intstd/core/types/int: V ) : stringstd/core/types/string: V

Show a time zone delta. Optional utcstd/time/utc/utc: () -> utc timescale for displaying a zero timezone delta (="Z"). Optional hmsep for the hour-minute separator (=":"). Optional hrwidth to give the minimal width of the hour field (=2).

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/time/timestampstd/time/timestamp, std/time/durationstd/time/duration, std/time/instantstd/time/instant, std/time/utcstd/time/utc, std/time/datestd/time/date, std/time/calendarstd/time/calendar, std/time/chronostd/time/chrono