the window strings is NOT quoted at this point; other cleanups
[unix-history] / usr / src / lib / libc / gen / ctime.3
CommitLineData
463d6749
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
2ad48aae 5.\" @(#)ctime.3 6.3 (Berkeley) %G%
463d6749 6.\"
3f00558b 7.TH CTIME 3 ""
463d6749
KM
8.UC 4
9.SH NAME
10ctime, localtime, gmtime, asctime, timezone \- convert date and time to ASCII
11.SH SYNOPSIS
12.nf
13.B char *ctime(clock)
14.B long *clock;
15.PP
2ad48aae 16.B #include <time.h>
463d6749
KM
17.PP
18.B struct tm *localtime(clock)
19.B long *clock;
20.PP
21.B struct tm *gmtime(clock)
22.B long *clock;
23.PP
24.B char *asctime(tm)
25.B struct tm *tm;
26.PP
27.B char *timezone(zone, dst)
28.fi
29.SH DESCRIPTION
30.I Ctime
31converts a time pointed to by
32.I clock
33such as returned by
34.IR time (2)
35into ASCII
36and returns a pointer to a
3726-character string
38in the following form.
39All the fields have constant width.
40.PP
41 Sun Sep 16 01:03:52 1973\\n\\0
42.PP
43.I Localtime
44and
45.I gmtime
46return pointers to structures containing
47the broken-down time.
48.I Localtime
49corrects for the time zone and possible daylight savings time;
50.I gmtime
51converts directly to GMT, which is the time UNIX uses.
52.I Asctime
53converts a broken-down time to ASCII and returns a pointer
54to a 26-character string.
55.PP
56The structure declaration from the include file is:
463d6749 57.PP
8eafd288 58.RS
463d6749 59.nf
5f90d5f0
KM
60.nr .0 .8i+\w'int tm_isdst'u
61.ta .5i \n(.0u \n(.0u+\w'/* 0-000'u+1n
8eafd288 62struct tm {
5f90d5f0
KM
63 int tm_sec; /* 0-59 seconds */
64 int tm_min; /* 0-59 minutes */
65 int tm_hour; /* 0-23 hour */
66 int tm_mday; /* 1-31 day of month */
67 int tm_mon; /* 0-11 month */
68 int tm_year; /* 0- year \- 1900 */
69 int tm_wday; /* 0-6 day of week (Sunday = 0) */
70 int tm_yday; /* 0-365 day of year */
71 int tm_isdst; /* flag: daylight savings time in effect */
8eafd288 72};
463d6749
KM
73.fi
74.RE
75.PP
463d6749
KM
76When local time is called for,
77the program consults the system to determine the time zone and
8eafd288
KM
78whether the U.S.A., Australian, Eastern European, Middle European,
79or Western European daylight saving time adjustment is appropriate.
80The program knows about various peculiarities in time conversion
81over the past 10-20 years; if necessary, this understanding can
82be extended.
463d6749
KM
83.PP
84.I Timezone
85returns the name of the time zone associated with its first argument,
86which is measured in minutes westward from Greenwich.
87If the second argument is 0, the standard name is used,
88otherwise the Daylight Saving version.
89If the required name does not appear in a table
90built into the routine,
91the difference from GMT is produced; e.g.
92in Afghanistan
93.I timezone(-(60*4+30), 0)
94is appropriate because it is 4:30 ahead of GMT
95and the string
96.B GMT+4:30
97is produced.
98.SH "SEE ALSO"
8eafd288 99gettimeofday(2), time(3)
463d6749
KM
100.SH BUGS
101The return values point to static data
102whose content is overwritten by each call.