NAME

tiktok — Extended clock functions.

synopsis

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

description

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.

clock-representation ::= date-time | duration
date-time ::= seconds:base
base ::= string-with-1-4-characters
duration ::= seconds
seconds ::= integer | nines-complement
integer ::= [ +|- ] digits
nines-complement ::= Pdigits | Ndigits

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

zulu
Is Greenwich Mean Time.
unix
The unix base time, 1 January 1970 GMT.
cMac
The Mac Classic base time, 1 January 1904 GMT.
JDAY
Julian day 1. This time base needs to be defined to do calendar conversions.
1AD
1 January AD 1, relative to 'JDAY'.
here
is local time, either the system base or relative to GMT.

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.

Calendar

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.

dura.0.day.hour.minute.second
with the day starting at midnight.

The proleptic Gregorian calendar is represented as

GREG.leap.year.month.day.hour.minute.second
with the day starting at midnight. Year -1 is 1 BC and year 1 is AD 1. There is no year 0.

The ISO week number is represented as

ISOW.0.year.week.day.hour.minute.second
with the day starting at midnight. Years are Gregorian years.

The ISO year and day number is represented as

ISOD.0.year.day.hour.minute.second
with the day starting at midnight. Years are Gregorian years.

The Julian day is represented as

JDAY.0.day.hour.minute.second
with the day starting at noon.

The Julian date is represented as

JULI.leap.year.month.day.hour.minute.second
with the day starting at midnight.

The Hebrew calendar is represented as

HEBR.leap.year.week.day.hour.minute.second
with the day starting at 18:00. Days actually start from sunset, but sunset computation depends on day of year and latitude. In normal years, the last month is 12 for Adar. In a leap year, the last two months are 12 for Adar I and 13 for Adar II.

The Islamic calendar is represented as

ISLM.leap.year.week.day.hour.minute.second
with the day starting at 18:00. Days actually start from sunset, but sunset computation depends on day of year and latitude. For religious use, the start of the month is based on actual observation of the crescent new moon and cannot be reduced to calculation.

The Persian calendar is represented as

PERS.leap.year.week.day.hour.minute.second
with the day starting at midnight.

The three Mayan calendars are represented as

MAYA.0:long-count:haab:tzolkin
long-count ::= baktun.katun.tun.uinal.kin
haab ::= period.day
tzolkin ::= period.day
Intercalary haab days are assigned to period 13.

The Bahai calendar is represented as

BAHA.leap.major-cycle.cycle.year.month.day .hour.minute.second
with the day starting at midnight.

The Indian civil calendar is represented as

ICIV.leap.year.week.day.hour.minute.second
with the day starting at midnight.

The Discordian is represented as

ERIS.leap.year.season.day.minute.second
with the day starting at 5:23AM. St Tibbs day is assigned day 5 of season 23.

tiktok easter returns the easter calendar representation for the Gregorian or Julian calendar.

Corrections

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).

SEE ALSO

wyrm_tiktokNewClockObj (3WY).