.MKTIME - convert time structure to time number.

Alternate Entry Name: _MKTIME

Usage:

B:
   timenum = .mktime(timestruct);
/* C users use ANSI standard "mktime" */

Where:

timestruct
is a pointer to a time structure, as described in "expl b lib .tm".
timenum
is an integer giving the number of seconds after 0:00 a.m. GMT on 1 January 1970. If the given "timestruct" can't be converted to a valid time number, .MKTIME returns -1.

Description:

.MKTIME converts a time structure into a time number. The time zone in the time structure is ignored; the other entries in the time structure are assumed to give a date and time in the current default time zone locale.

The time structure passed to .MKTIME does not have to conform to the usual restrictions on time structures. The _TM_WDAY and _TM_YDAY fields are ignored, so they don't have to agree with the date as given by other fields in the structure. Similarly, other elements in the structure are not subject to their usual range restrictions. For example, _TM_MON (the month) can be outside the usual range 0 to 11.

When .MKTIME receives a pointer to a time structure that doesn't meet the usual restrictions, .MKTIME converts the elements in the structure so they do conform. For example, if the structure gives the date as 32 December 1994, this is changed to 1 January 1995. The _TM_WDAY and _TM_YDAY elements are also adjusted if necessary.

As an example of how this is useful, suppose you have a time structure for today and you want to find the date 90 days from today. Simply add 90 to the _TM_MDAY field and call .MKTIME with a pointer to the structure. .MKTIME adjusts all the fields in the structure to refer to the appropriate date.

See Also:

expl b lib .tm
for the layout and field names of the time structure.

Copyright © 1996, Thinkage Ltd.