.TM - convert time number to time structure.

Alternate Entry Name: _TM

Usage:

B:
   %b/manif/t_ctrl
   .tm(tsptr, tlocale, timenum);
C:
   #include <time.h>
   #include <t_ctrl.h>
   void _tm(struct tm *tsptr, _T_locale tlocale,
            time_t timenum);

Examples:

/* Obtain current time in Eastern Standard zone */
auto estloc, timenum, tsptr[_TM_SIZE];
estloc = .tlocale("US/EST");
timenum = .ctime();
.tm(tsptr,estloc,timenum);

Where:

tsptr
points to a region of memory where .TM can store the time structure corresponding to the given time number.
tlocale
specifies a time zone locale reference. The date/time information stored where "tsptr" points is expressed relative to this locale. Normally, this would be zero, indicating the "default" locale. Howver, on occasion a different reference token generated by .TSWITCH or .TLOCALE might also be used.
timenum
is a date/time expressed as a number of seconds after 00:00 GMT on 1 January 1970.

Description:

.TM converts a time number into a time structure. The format of the time structure is given below, expressed in the form used by the C programming language:

struct tm {
    int tm_sec;     /* _TM_SEC    seconds (0-60) */
    int tm_min;     /* _TM_MIN    minutes (0-59) */
    int tm_hour;    /* _TM_HOUR   hours (0-23) */
    int tm_mday;    /* _TM_MDAY   month day (1-31) */
    int tm_mon;     /* _TM_MON    month (0-11) */
    int tm_year;    /* _TM_YEAR   year - 1900 */
    int tm_wday;    /* _TM_WDAY   day of week (0-6) */
    int tm_yday;    /* _TM_YDAY   year day (0-365) */
    int tm_isdst;   /* _TM_ISDST  daylight savings flag
                     *            >0 daylight time
                     *            =0 standard time
                     *            <0 Can't tell */
    char *tm_zone;  /* _TM_ZONE   time zone name */
    long tm_gmtoff; /* _TM_GMTOFF seconds from GMT
                     * positive -> east of Greenwich */
};

This format is useful for extracting pieces of date/time information. It can also be passed to the .TMFMT function to be formatted into a variety of date/time string formats. The names like _TM_SEC, that shown above are the names of B manifests defined in B/MANIF/T_CTRL that can be used to access these fields. The manifest _TM_SIZE is also supplied to give the B size of a vector to hold a time structure.

Notes:

The "tm_zone" field in a "tm" structure is always a 36-bit machine pointer, with the word offset in the upper half of the word and a character offset/segment number in the lower half. Thus it has the format of a C pointer, not a B pointer. If necessary, you can pass this pointer to "printf" to print out the time zone name. If you must get a copy of the string, you can pass the pointer to CONCAT.

See Also:

expl b tz
for more information on time zone locale references.
expl b lib .ctime
to get the current time as a time number.
expl b lib .mktime
for the inverse function that converts a time structure to a time number.
expl b lib .tfmt
for formatting date/time strings.

Copyright © 1996, Thinkage Ltd.