The dtitos instruction converts the date and time from an internal form to the tm structure form.
Synopsis
dtitos(type.src, type.dst)
Description
The dtitos instruction converts the date and time from the internal system representation to tm structure form. The type.src argument should contain a number representing the internal representation of time (number of seconds since 00:00:00 GMT, January 1, 1970). It is recommended that the integer type be used for this argument. The resulting tm structure is put in type.dst (that is, type.dst defines a starting address for the result).
The dtitos instruction returns 0 in script register 0 (r.0) if the conversion is successful. r.0 contains -2 if TSM could not allocate enough space in script memory to store the result.
Example
In the following example, the script plays the system date and time, then says good-bye and hangs up. Note that phrase numbers for the days of the week and month of the year in the stdspch.pl play file are offset from Sunday and January by the values obtained in TM_WDAY and TM_MON, respectively.
#define TM 8
#define TM_SEC 8 /* seconds after the minute (0-59) */
#define TM_MIN 12 /* minutes after the hour (0-59) */
#define TM_HOUR 16 /* hour since midnight (0-23) */
#define TM_MDAY 20 /* day of the month (1-31) */
#define TM_MON 24 /* months since January (0-11) */
#define TM_YEAR 28 /* years since 1900 */
#define TM_WDAY 32 /* days since Sunday (0-6) */
#define TM_YDAY 36 /* days since January 1st (0-365) */
#define TM_ISDST 40 /* flag for daylight savings time */
/* (non-zero if alt. timezone in effect) */
#define WKDAYPH 44
#define MONTHPH 48
tfile("stdspch.pl")
dtitos(time.0, ch.TM)
tic('a')
talk("date")
load(int.WKDAYPH, "sunday?")
incr(int.WKDAYPH, int.TM_WDAY)
talk(int.WKDAYPH)
load(int.MONTHPH, "january")
incr(int.MONTHPH, int.TM_MON)
talk(int.MONTHPH)
tnum(int.TM_MDAY)
tnum(19)
tnum(int.TM_YEAR)
sleep(2)
talk("time")
tnum(int.TM_HOUR)
tnum(int.TM_MIN)
sleep(2)
talk("goodbye")
quit()
See also