2.9BSD/usr/man/cat3/ctime.3
CTIME(3) UNIX Programmer's Manual CTIME(3)
NAME
ctime, localtime, gmtime, asctime, timezone - convert date
and time to ASCII
SYNOPSIS
char *ctime(clock)
long *clock;
#include <time.h>
struct tm *localtime(clock)
long *clock;
struct tm *gmtime(clock)
long *clock;
char *asctime(tm)
struct tm *tm;
char *timezone(zone, dst)
DESCRIPTION
_C_t_i_m_e converts a time pointed to by _c_l_o_c_k such as returned
by _t_i_m_e(2) into ASCII and returns a pointer to a 26-
character string in the following form. All the fields have
constant width.
Sun Sep 16 01:03:52 1973\n\0
_L_o_c_a_l_t_i_m_e and _g_m_t_i_m_e return pointers to structures contain-
ing the broken-down time. _L_o_c_a_l_t_i_m_e corrects for the time
zone and possible daylight savings time; _g_m_t_i_m_e converts
directly to GMT, which is the time UNIX uses. _A_s_c_t_i_m_e con-
verts a broken-down time to ASCII and returns a pointer to a
26-character string.
The structure declaration from the include file is:
struct tm { /* see ctime(3) */
short tm_sec;
short tm_min;
short tm_hour;
short tm_mday;
short tm_mon;
short tm_year;
short tm_wday;
short tm_yday;
short tm_isdst;
};
These quantities give the time on a 24-hour clock, day of
month (1-31), month of year (0-11), day of week (Sunday =
Printed 7/31/83 1
CTIME(3) UNIX Programmer's Manual CTIME(3)
0), year - 1900, day of year (0-365), and a flag that is
nonzero if daylight saving time is in effect.
When local time is called for, the program consults the sys-
tem to determine the time zone and whether the standard
U.S.A. daylight saving time adjustment is appropriate. The
program knows about the peculiarities of this conversion in
1974 and 1975; if necessary, a table for these years can be
extended.
_T_i_m_e_z_o_n_e returns the name of the time zone associated with
its first argument, which is measured in minutes westward
from Greenwich. If the second argument is 0, the standard
name is used, otherwise the Daylight Saving version. If the
required name does not appear in a table built into the rou-
tine, the difference from GMT is produced; e.g. in Afghan-
istan _t_i_m_e_z_o_n_e(-(_6_0*_4+_3_0), _0) is appropriate because it is
4:30 ahead of GMT and the string GMT+4:30 is produced.
SEE ALSO
time(2)
BUGS
The return values point to static data whose contents are
overwritten by each call.
Printed 7/31/83 2