ObjectScript assigns each day an integer value, starting with 0 for 12/31/1840 up to 2980013 for 12/31/9999. Another example: 1/1/2018 is 64649. There are functions for converting a date from a number of acceptable external formats to its (internal) integer format, and vice versa. Check the documentation for the details. Similarly, ObjectScript counts each second since midnight each day, and provides functions for conversion of time.
Related to the date functions is an ObjectScript system variable called $Horolog. System variables act like functions with no arguments. $Horolog returns the day number for today, followed by the count of seconds since midnight, separated by a comma. The date functions and $Horolog provide an easy way for you to accept dates in a variety of formats, verify that the dates are valid, and perform date arithmetic.
The date functions are $ZDate (internal->external), and $ZDateH (external->internal). These functions have multiple arguments, which the documentation describes. For this tutorial, you only need to understand the first (internal or external date to be converted), second (external format code), and ninth (error code to be returned) arguments.
The first example shows valid and invalid dates, and the success or failure of conversion by the $ZDateH function. Expressions using T (for today), and adding or subtracting days, are also valid. By default, $ZDateH generates an error for invalid dates, but its ninth argument allows you to specify an error code it should return instead.
USER>write $zdateh("9/21/1999", 5,,,,,,, -1) 57972 USER>write $zdateh("21/9/1999", 5,,,,,,, -1) -1 USER>write $zdateh("21 SEP", 5,,,,,,, -1) 57972 USER>write $zdateh("SEP 21 1998", 5,,,,,,, -1) 57607 USER>write $zdateh("2 29 2000", 5,,,,,,, -1) 58133 USER>write $zdateh("2.29.1999", 5,,,,,,, -1) -1 USER>write $zdateh("T+12", 5,,,,,,, -1) 57985 USER>write $zdateh("MAT 3", 5,,,,,,, -1) -1 USER>
The second example shows $Horolog, and several formats of $ZDate.
USER>write $horolog 57973,50111 USER>write $zdate($horolog) 09/22/99 USER>write $zdate($horolog, 2) 22 Sep 99 USER>write $zdate($horolog, 3) 1999-09-22 USER>