All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.
@(#)ctime.3 6.5 (Berkeley) 03/04/87
extern char *tzname[2];void tzset()
void tzsetwall()
char *ctime(clock) time_t *clock;
#include <time.h>
char *asctime(tm) struct tm *tm;
struct tm *localtime(clock) time_t *clock;
struct tm *gmtime(clock) time_t *clock;
char *timezone(zone, dst)
Tzsetwall sets things up so that localtime returns the best available approximation of local wall clock time.
Ctime converts a long integer, pointed to by clock, such as returned by time(2) into ASCII adn 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
Localtime and gmtime return pointers to structures containing the broken-down time. Localtime corrects for the time zone and possible daylight savings time; gmtime converts directly to GMT, which is the time UNIX uses. Asctime converts a broken-down time to ASCII and returns a pointer to a 26-character string.
The structure declaration from the include file is:
.nr .0 .8i+\w'int tm_isdst'u struct tm { int tm_sec; /* 0-59 seconds */ int tm_min; /* 0-59 minutes */ int tm_hour; /* 0-23 hour */ int tm_mday; /* 1-31 day of month */ int tm_mon; /* 0-11 month */ int tm_year; /* 0- year - 1900 */ int tm_wday; /* 0-6 day of week (Sunday = 0) */ int tm_yday; /* 0-365 day of year */ int tm_isdst; /* flag: daylight savings time in effect */ char **tm_zone; /* abbreviation of timezone name */ long tm_gmtoff; /* offset from GMT in seconds */ };
Tm_isdst is non-zero if a time zone adjustment such as Daylight Savings time is in effect.
Tm_gmtoff is the offset (in seconds) of the time represented from GMT, with positive values indicating East of Greenwich.
Timezone remains for compatibility reasons only; it's impossible to reliably map timezone's arguments (a "minutes west of GMT" value and a "daylight saving time in effect" flag) to a time zone abbreviation. Its current effect is to return the time zone abbreviation associated with local time no matter what its arguments, which is probably what people wanted anyway. Programs that in the past used the timezone function should examine localtime(&clock)->tm_zone to find the correct time zone abbreviation to use.
/etc/zoneinfo/localtime local time zone file