1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
.TH CTIME 3
.SH NAME
ctime, localtime, gmtime, asctime, tm2sec, timezone \- convert date and time
.SH SYNOPSIS
.B #include <u.h>
.br
.B #include <libc.h>
.PP
.ta \w'\fLchar* 'u
.B
char* ctime(long clock)
.PP
.B
Tm* localtime(long clock)
.PP
.B
Tm* gmtime(long clock)
.PP
.B
char* asctime(Tm *tm)
.PP
.B
long tm2sec(Tm *tm)
.SH DESCRIPTION
.I Ctime
converts a time
.I clock
such as returned by
.IR time (3)
into
.SM ASCII
(sic)
and returns a pointer to a
30-byte string
in the following form.
All the fields have constant width.
.PP
.B
Wed Aug 5 01:07:47 EST 1973\en\e0
.PP
.I Localtime
and
.I gmtime
return pointers to structures containing
the broken-down time.
.I Localtime
corrects for the time zone and possible daylight savings time;
.I gmtime
converts directly to GMT.
.I Asctime
converts a broken-down time to
.SM ASCII
and returns a pointer
to a 30-byte string.
.IP
.EX
.ta 6n +\w'char 'u +\w'zone[4]; 'u
typedef
struct {
int sec; /* seconds (range 0..59) */
int min; /* minutes (0..59) */
int hour; /* hours (0..23) */
int mday; /* day of the month (1..31) */
int mon; /* month of the year (0..11) */
int year; /* year A.D. \- 1900 */
int wday; /* day of week (0..6, Sunday = 0) */
int yday; /* day of year (0..365) */
char zone[4]; /* time zone name */
int tzoff; /* time zone delta from GMT */
} Tm;
.EE
.PP
.I Tm2sec
converts a broken-down time to
seconds since the start of the epoch.
It ignores
.BR wday ,
and assumes the local time zone
if
.B zone
is not
.BR GMT .
.SH SOURCE
.B \*9/src/lib9/date.c
.br
.B \*9/src/lib9/ctime.c
.SH "SEE ALSO"
.IR date (1),
.IR time (3)
.SH BUGS
The return values point to static data
whose content is overwritten by each call.
.PP
Daylight Savings Time is ``normal'' in the Southern hemisphere.
.PP
These routines are not equipped to handle non-\c
.SM ASCII
text, and are provincial anyway.
.PP
To avoid name conflicts with the underlying system,
.IR ctime ,
.IR localtime ,
.IR gmtime ,
.IR asctime ,
and
.I tm2sec
are preprocessor macros defined as
.IR p9ctime ,
.IR p9localtime ,
.IR p9gmtime ,
.IR p9asctime ,
and
.IR p9tm2sec ;
see
.IR intro (3).
|