next up previous contents index
Next: File System Interface Up: Main Functions 2 Previous: Current Directory   Contents   Index

Date and Time

(string) DateString()
This function returns a string containing the date and time in the format
Tue Jun 12 23:42:38 PDT 2001

(int) Time()
This returns a system time value, which can be converted to more useful output by TimeToString or TimeToVals. Actually, the returned value is the number of seconds since the start of the year 1970.

(int) MakeTime(array, gmt)
This function takes the time fields specified in the array and returns a time value is if returned from Time. If the boolean argument gmt is nonzero, the interpretation is GMT, otherwise local time. The array must be size 9 or larger, with the values set as when returned by the TimeToVals function (below).

Under Windows, the gmt argument is ignored and local time is used.

(string) TimeToString(time, gmt)
Given a time value as returned from Time, this returns a string in the form
Tue Jun 12 23:42:38 PDT 2001

If the boolean argument gmt is nonzero, GMT will be used, otherwise the local time is used.

(string) TimeToVals(time, gmt, array)
Given a time value as returned from Time, this breaks out the time/date into the array. The array must have size 9 or larger. If the boolean argument gmt is nonzero, GMT is used, otherwise local time is used.

The array values are set as follows.

array[0] seconds (0 - 59).
array[1] minutes (0 - 59).
array[2] hours (0 - 23).
array[3] day of month (1 - 31).
array[4] month of year (0 - 11).
array[5] year - 1900.
array[6] day of week (Sunday = 0).
array[7] day of year (0 - 365).
array[8] 1 if summer time is in effect, or 0.

The return value is a string containing an abbreviation of the local timezone name, except under Windows where the return is an empty string.

(int) MilliSec()
This returns the elapsed time in milliseconds since midnight January 1, 1970 GMT. This can be used to measure script execution time.

(int) StartTiming(array)
This will initialize the values in the array, which must have size 3 or larger, for later use by the StopTiming function. The return value is always 1.

(int) StopTiming(array)
This will place time differences (in seconds) into the array, since the last call to StartTiming (with the same argument). The array must have size 3 or larger. the components are:

0 Elapsed wall-clock time
1 Elapsed user time
2 Elapsed system time

The user time is the time the cpu spent executing in user mode. The system time is the time spent in the system executing on behalf of the process. This uses the UNIX getrusage or times system calls, which may not be available on all systems. If support is not available, e.g., in Windows, the user and system entries will be zero, but the wall-clock time is valid. This function always returns 1.


next up previous contents index
Next: File System Interface Up: Main Functions 2 Previous: Current Directory   Contents   Index
Stephen R. Whiteley 2022-05-28