Epoch Conversion (E) |
|
|
Epoch values represent a moment in time in a time zone independent manner. They are stored as a number of seconds since 1 January 1970 GMT (more correctly UTC).
The epoch conversion code converts an epoch value from its internal day number to one of a number of external formats or vice versa.
The full format of this conversion code is an extension of the D date conversion code:
E {U} {y} {c} {fmt} {[f1, f2, f3, f4, f5, f6, f7]}
where
The following special codes are recognised as part of the E conversion code for ISO8601 format output. These may not be used with any other conversion elements:
Four digit year number, two digit ISO week number, one digit day of week.
Four digit year number, two digit ISO week number, one digit day of week with hyphen separators.
Four digit year number, two digit month number, two digit day number, two digit hours, two digit minutes, two digit seconds.
Four digit year number, two digit month number, two digit day number, two digit hours, two digit minutes, two digit seconds with separators.
Time Zones
Conversion of an epoch value to an external form date and time is dependent on the time zone for which the conversion is performed. On entry to QM, the time zone to be used is taken from the operating system TZ environment variable for the user's process. If this has not been set, the value of the TZ variable when QM was started is used. If this is also not set, GMT is used.
The time zone name is stored in a private configuration parameter named TIMEZONE. This can be modified from, for example, the LOGIN paragraph, using the CONFIG command or from within a program using the QMBasic SET.TIMEZONE statement.
Output Conversion of Epoch Values
The following examples show the result of output conversion of a value of 1234567890 in time zone EST with various conversion codes. Where affected by DATE.FORMAT setting, both forms are shown.
Input Conversion of Epoch Values
Input conversion with the E code is much more restricted than the range of formats possible on output conversion. In practical use of the epoch date system, it is likely that the date and time are entered as separate items. In this case, it may be more flexible to use the D and MT conversions on the two components separately and then use the MVEPOCH() function to convert these to an epoch value.
The input data must always consist of a date followed by a time. The date must contain all three elements (day, month, year).
The simplest E conversion is just the letter E. This may be followed by the D, M and Y elements to override the default sequence of the date components. Use of a trailing T to represent the time is valid for consistency but is otherwise ignored as it must be the last element in the data to be converted. Use of any other conversion code elements may have unspecified effects.
There is some flexibility to the order in which the components of the date may occur in the input data. Where an alphabetic month name is used, this is processed first and must be at least three characters. Numeric components are then assumed to be in the order of the remaining elements of the conversion code. Thus with a code of EDMY, '1 Jun 94' and 'Jun 1 94' would both be treated as 1 June 1994.
For dates entered as two digits, year number values in the range 30 to 99 are assumed to be 1930 to 1999 and 0 to 29 are assumed to be 2000 to 2029. This 100 year window can be moved using the YEARBASE configuration parameter. and the order of these defaults to day.
The time must be entered in the form hh:mm:ss or hh:mm where the colon may be any non-numeric character. If the seconds are omitted, a default of zero is used.
See also: Date, Times and Epoch Values, EPOCH(), MVDATE(), MVDATE.TIME(), MVEPOCH(), MVTIME(), SET.TIMEZONE |