Manual Page Result
0
Command: ctime | Section: 3 | Source: UNIX v10 | File: ctime.3
CTIME(3) Library Functions Manual CTIME(3)
NAME
ctime, localtime, gmtime, asctime, timezone - convert date and time to
ASCII
SYNOPSIS
#include <time.h>
char *ctime(clock)
long *clock;
struct tm *localtime(clock)
long *clock;
struct tm *gmtime(clock)
long *clock;
char *asctime(tm)
struct tm *tm;
char *timezone(zone, dst)
DESCRIPTION
Ctime converts a time pointed to by clock such as returned by time(2)
into ASCII and returns a pointer to a 26-character string in the fol-
lowing 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 bro-
ken-down time. Localtime corrects for the time zone and possible day-
light 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.
struct tm {
int tm_sec; seconds (range 0..59)
int tm_min; minutes (0..59)
int tm_hour; hours (0..23)
int tm_mday; day of the month (1..31)
int tm_mon; month of the year (0..11)
int tm_year; year A.D. - 1900
int tm_wday; day of week (0..6, Sunday = 0)
int tm_yday; day of year (0..365)
int tm_isdst; zero means normal time, nonzero means daylight saving time
};
When local time is called for, the program consults the system to de-
termine the time zone and whether the standard U.S.A. daylight saving
time adjustment is appropriate. The peculiarities of this conversion
are read from the file which contains lines of the form
y0 y1 bmon bday boff emon eday eoff
meaning that for years between y0 and y1 inclusive, daylight saving
time begins (ends) boff (eoff) days after the first Sunday after the
day bmon/bday (emon/eday).
Timezone 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 routine, the difference from GMT is produced. Thus, as
Afghanistan is 4:30 ahead of GMT, timezone(-(60*4+30), 0) returns
"GMT+4:30".
SEE ALSO
time(2), timec(3)
BUGS
The return values point to static data whose content is overwritten by
each call.
CTIME(3)