@node ctime, time @subheading Syntax @example #include char *ctime(const time_t *cal); @end example @subheading Description This function returns an ASCII representation of the time in @var{cal}. This is equivalent to @code{asctime(localtime(cal))}. @xref{asctime}. @xref{localtime}. @subheading Return Value The ascii representation of the time. @subheading Portability @portability ansi, posix @c ---------------------------------------------------------------------- @node asctime, time @subheading Syntax @example #include char *asctime(const struct tm *tptr); @end example @subheading Description This function returns an ASCII representation of the time represented by @var{tptr}. The string returned is always 26 characters and has this format: @example Sun Jan 01 12:34:56 1993\n\0 @end example The string pointed to is in a static buffer and will be overwritten with each call to asctime. The data should be copied if it needs to be preserved. The layout of the @code{struct tm} structure is like this: @example struct tm @{ int tm_sec; /* seconds after the minute [0-60] */ int tm_min; /* minutes after the hour [0-59] */ int tm_hour; /* hours since midnight [0-23] */ int tm_mday; /* day of the month [1-31] */ int tm_mon; /* months since January [0-11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0-6] */ int tm_yday; /* days since January 1 [0-365] */ int tm_isdst; /* Daylight Savings Time flag */ long tm_gmtoff; /* offset from GMT in seconds */ char * tm_zone; /* timezone abbreviation */ @}; @end example @subheading Return Value A pointer to the string. @subheading Portability @portability ansi, posix @subheading Example @example time_t now; time(&now); printf("The current time is %s", asctime(localtime(&now))); @end example @c ---------------------------------------------------------------------- @node gmtime, time @subheading Syntax @example #include struct tm *gmtime(const time_t *tod); @end example @subheading Description Converts the time represented by @var{tod} into a structure. The return structure has this format: @example struct tm @{ int tm_sec; /* seconds after the minute [0-60] */ int tm_min; /* minutes after the hour [0-59] */ int tm_hour; /* hours since midnight [0-23] */ int tm_mday; /* day of the month [1-31] */ int tm_mon; /* months since January [0-11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0-6] */ int tm_yday; /* days since January 1 [0-365] */ int tm_isdst; /* Daylight Savings Time flag */ long tm_gmtoff; /* offset from GMT in seconds */ char * tm_zone; /* timezone abbreviation */ @}; @end example @subheading Return Value A pointer to a static structure which is overwritten with each call. @subheading Portability @portability ansi, posix @subheading Example @example time_t x; struct tm *t; time(&x); t = gmtime(&t); @end example @c ---------------------------------------------------------------------- @node localtime, time @subheading Syntax @example #include struct tm *localtime(const time_t *tod); @end example @subheading Description Converts the time represented by @var{tod} into a structure, correcting for the local timezone. See @ref{gmtime}, for the description of @code{struct tm}. @subheading Return Value A pointer to a static structure which is overwritten with each call. @subheading Portability @portability ansi, posix @c ---------------------------------------------------------------------- @node mktime, time @subheading Syntax @example #include time_t mktime(struct tm *tptr); @end example @subheading Description This function converts a time structure into the number of seconds since 00:00:00 GMT 1/1/1970. It also attempts to normalize the fields of @var{tptr}. The layout of a @code{struct tm} is as follows: @example struct tm @{ int tm_sec; /* seconds after the minute [0-60] */ int tm_min; /* minutes after the hour [0-59] */ int tm_hour; /* hours since midnight [0-23] */ int tm_mday; /* day of the month [1-31] */ int tm_mon; /* months since January [0-11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0-6] */ int tm_yday; /* days since January 1 [0-365] */ int tm_isdst; /* Daylight Savings Time flag */ long tm_gmtoff; /* offset from GMT in seconds */ char * tm_zone; /* timezone abbreviation */ @}; @end example If you don't know whether daylight saving is in effect at the moment specified by the contents of @var{tptr}, set the @code{tm_isdst} member to -1, which will cause @code{mktime} to compute the DST flag using the data base in the @file{zoneinfo} subdirectory of your main DJGPP installation. This requires that you set the environment variable @code{TZ} to a file in that directory which corresponds to your geographical area. @subheading Return Value The resulting time, or -1 if the time in @var{tptr} cannot be described in that format. @subheading Portability @portability ansi, posix @c ---------------------------------------------------------------------- @node tzset, time @subheading Syntax @example #include extern char *tzname[2]; void tzset(void); @end example @subheading Description This function initializes the global variable @code{tzname} according to environment variable @code{TZ}. After the call, @code{tzname} holds the specifications for the time zone for the standard and daylight-saving times. @subheading Return Value None. @subheading Portability @portability !ansi, posix @c ---------------------------------------------------------------------- @node tzsetwall, time @subheading Syntax @example #include void tzsetwall(void); @end example @subheading Description This function sets up the time conversion information used by @code{localtime} (@pxref{localtime}) so that @code{localtime} returns the best available approximation of the local wall clock time. @subheading Return Value None. @subheading Portability @portability !ansi, !posix