tiktok base clock-representation
tiktok seconds clock-representation [ base ]
tiktok define date-time date-time
tiktok relation date-time date-time
tiktok add clock-representation clock-representation
tiktok subtract clock-representation clock-representation
tiktok symetricsubtract clock-representation clock-representation
tiktok scale duration real-number
tiktok maximum clock-representation clock-representation
tiktok minimum clock-representation clock-representation
tiktok compare clock-representation clock-representation
tiktok clock calendar-representation
tiktok calendar clock-representation calendar-type
tiktok easter year [ gregorian|julian ]
tiktok utc [ add|subtract|+|- ] date-time
tiktok gps [ add|subtract|+|- ] date-time
tiktok local [ add|subtract|+|- ] date-time
TimeValue is a machine independent date and time type. The range is approximately 200 billion years (to a one second resolution). combined with time base name, such as a time zone name as a 32 bit number.
Time values are either durations or is relative to some base named with a four character designation. If two bases have bases have direct or indirect relations, these routines will do the base conversions automatically.
Clock values are regarded as date-times or durations of time. For example an duration can be added to date-time, or two date-times can be subtracted to produce an duration, but date-time cannot be added to a date-time, nor a date-time subtracted from an duration.
Fixed width nines-complement is the format generated by this package for seconds instead of normal decimal integers. If the bases are the same, this form can be compared as strings with the same result as comparing clocks. P and N stand for positive (+) and negative (-).
Date-times are given relative to a base designation, a one to four character name. The base designations are packed into a long integer value. The base values 0 and -1 are reserved and cannot be used. Base 0 is used to indicate the clock is a duration rather than a date-time; base -1 used to indicate a missing or default base on some calls. The system clock base, the same value returned by [clock seconds] has the base value 'syst'.
If the system clock can be related to Greenwich Mean Time, additional bases are defined
The difference between 'here' and 'zulu' should be current timezone difference only.
tiktok base extracts the base of the clock-representation. This will be an empty string if it is a duration.
tiktok seconds extracts the seconds of the clock-representation. The clock is converted to base first if it is specified.
tiktok define declares that two times, t1=base1+seconds1 and t2=base2+seconds2 are equal, base1=base2+seconds2−seconds1 . If this definition is consistent with previous definitions, it is rememberred. Otherwise an error is returned. date operations.
tiktok relation returns the relative number of seconds between two times, t1=base1+seconds1 and t2=base1+seconds2 , returning seconds2−seconds1 . If the times have different but related bases, the bases are normalised. If the bases are different and no relation is defined between them, an error is returned.
tiktok add adds two durations or adds a duration to a date-time. Two date-times cannot be added.
tiktok subtract subtracts two durations, subtracts a duration from a date-time, or subtracts two date-times to get the duration between them. A date-time be subtracted from a duration. If two date-times have no defined relation, an error is returned.
tiktok symetricsubtract subtracts two date-times and returns a two element list. The first element is true if the first date-time is earlier, false if later. The second element is the absolute value of the duration between the date-times. If two date-times have no defined relation, an error is returned.
tiktok scale scales a duration (multplies by) by a scalar factor. A date-time cannot be scaled.
tiktok maximum returns the later of two date-times or the longer of two durations. A date-time cannot be compared to a duration. A negative duration is less than any positive duration. If two date-times have no defined relation, an error is returned.
tiktok minimum returns the earlier of two date-times or the shorter of two durations. A date-time cannot be compared to a duration. A negative duration is less than any positive duration. If two date-times have no defined relation, an error is returned.
tiktok compare compares two date-times or two durations. A date-time cannot be compared to a duration. Errors are not returned; 0 is returned for undefined comparions. Errors can be detected by calling tiktok subtract. A negative duration is less than any positive duration.
This code is adapted from javascript at fourmilab.
A number of calendar conversions are provided to and from a date-time. Calendar dates are represented as a calendar name (one or more letters), a dot, a leap indicator, a dot, and various dot separated integers. The last three integers are hour, minute, and seconds from start of day. The other interpretation of the other integers is calendar dependent. The leap indicator is '1' if this is a leap year, otherwise an '0'.
The calendar calculations do not include local timezone or other modifications. These are handled by adding or subtracting corrective durations to the date-time before and after calendar conversions. Not all calendars define the start of day as midnight: the hours given are the hours from the calendar's start of day.
tiktok clock converts a calendar representation to a clock-representation. The calendar type is encoded into the calendar representation.
tiktok calendar converts a clock-representation to the requested calendar representation.
Durations can be expressed as a durations calendar.
The proleptic Gregorian calendar is represented as
The ISO week number is represented as
The ISO year and day number is represented as
The Julian day is represented as
The Julian date is represented as
The Hebrew calendar is represented as
The Islamic calendar is represented as
The Persian calendar is represented as
The three Mayan calendars are represented as
The Bahai calendar is represented as
The Indian civil calendar is represented as
The Discordian is represented as
tiktok easter returns the easter calendar representation for the Gregorian or Julian calendar.
tiktok utc adds or subtracts the number of leap seconds before the given date. This converts between UTC and TAI. If direction is add, the number of seconds is added (TAI to UTC); if subtract, the seconds are subtracted (UTC to TAI).
tiktok gps adds or subtracts the number of leap seconds before the given date that have applied to GPS time. This converts between GPS and TAI. If direction is add, the number of seconds is added (TAI to GPS); if subtract, the seconds are subtracted (GPS to TAI).
tiktok local adds or subtracts the local time zone offset from GMT. This includes all time zone conversions currently in effect, including daylight savings time if appropriate. This converts between local and GMT. If direction is add, the number of seconds is added (GMT to local); if subtract, the seconds are subtracted (local to GMT).