|
|
1.1 root 1: .TH CTIME 3 "26 June 1983"
2: .UC 4
3: .SH NAME
4: ctime, localtime, gmtime, asctime, timezone \- convert date and time to ASCII
5: .SH SYNOPSIS
6: .nf
7: .B char *ctime(clock)
8: .B long *clock;
9: .PP
10: .B #include <sys/time.h>
11: .PP
12: .B struct tm *localtime(clock)
13: .B long *clock;
14: .PP
15: .B struct tm *gmtime(clock)
16: .B long *clock;
17: .PP
18: .B char *asctime(tm)
19: .B struct tm *tm;
20: .PP
21: .B char *timezone(zone, dst)
22: .fi
23: .SH DESCRIPTION
24: .I Ctime
25: converts a time pointed to by
26: .I clock
27: such as returned by
28: .IR time (2)
29: into ASCII
30: and returns a pointer to a
31: 26-character string
32: in the following form.
33: All the fields have constant width.
34: .PP
35: Sun Sep 16 01:03:52 1973\\n\\0
36: .PP
37: .I Localtime
38: and
39: .I gmtime
40: return pointers to structures containing
41: the broken-down time.
42: .I Localtime
43: corrects for the time zone and possible daylight savings time;
44: .I gmtime
45: converts directly to GMT, which is the time UNIX uses.
46: .I Asctime
47: converts a broken-down time to ASCII and returns a pointer
48: to a 26-character string.
49: .PP
50: The structure declaration from the include file is:
51: .PP
52: .RS
53: .nf
54: struct tm {
55: int tm_sec;
56: int tm_min;
57: int tm_hour;
58: int tm_mday;
59: int tm_mon;
60: int tm_year;
61: int tm_wday;
62: int tm_yday;
63: int tm_isdst;
64: };
65: .fi
66: .RE
67: .PP
68: These quantities give the time on a 24-hour clock,
69: day of month (1-31), month of year (0-11), day of week
70: (Sunday = 0), year \- 1900, day of year (0-365),
71: and a flag that is nonzero if daylight saving time is in effect.
72: .PP
73: When local time is called for,
74: the program consults the system to determine the time zone and
75: whether the U.S.A., Australian, Eastern European, Middle European,
76: or Western European daylight saving time adjustment is appropriate.
77: The program knows about various peculiarities in time conversion
78: over the past 10-20 years; if necessary, this understanding can
79: be extended.
80: .PP
81: .I Timezone
82: returns the name of the time zone associated with its first argument,
83: which is measured in minutes westward from Greenwich.
84: If the second argument is 0, the standard name is used,
85: otherwise the Daylight Saving version.
86: If the required name does not appear in a table
87: built into the routine,
88: the difference from GMT is produced; e.g.
89: in Afghanistan
90: .I timezone(-(60*4+30), 0)
91: is appropriate because it is 4:30 ahead of GMT
92: and the string
93: .B GMT+4:30
94: is produced.
95: .SH "SEE ALSO"
96: gettimeofday(2), time(3)
97: .SH BUGS
98: The return values point to static data
99: whose content is overwritten by each call.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.