manual page distributed with 4.1BSD
[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.\"
5.\" @(#)ctime.3 4.1 (Berkeley) %G%
6.\"
7.TH CTIME 3
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
16.B #include <time.h>
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:
57.RS
58.PP
59.nf
60.so /usr/include/time.h
61.fi
62.RE
63.PP
64These quantities give the time on a 24-hour clock,
65day of month (1-31), month of year (0-11), day of week
66(Sunday = 0), year \- 1900, day of year (0-365),
67and a flag that is nonzero if daylight saving time is in effect.
68.PP
69When local time is called for,
70the program consults the system to determine the time zone and
71whether the standard U.S.A. daylight saving time adjustment is
72appropriate.
73The program knows about the peculiarities
74of this conversion in 1974 and 1975;
75if necessary,
76a table for these years can be extended.
77.PP
78.I Timezone
79returns the name of the time zone associated with its first argument,
80which is measured in minutes westward from Greenwich.
81If the second argument is 0, the standard name is used,
82otherwise the Daylight Saving version.
83If the required name does not appear in a table
84built into the routine,
85the difference from GMT is produced; e.g.
86in Afghanistan
87.I timezone(-(60*4+30), 0)
88is appropriate because it is 4:30 ahead of GMT
89and the string
90.B GMT+4:30
91is produced.
92.SH "SEE ALSO"
93time(2)
94.SH BUGS
95The return values point to static data
96whose content is overwritten by each call.