chiark / gitweb /
sort out cli dir stuff
[inn-innduct.git] / doc / man / parsedate.3
1 .\" $Revision: 6312 $
2 .TH PARSEDATE 3
3 .SH NAME
4 parsedate \- convert time and date string to number
5 .SH SYNOPSIS
6 .nf
7 .ta \w'    unsigned long    'u
8 .B "#include <sys/types.h>"
9
10 .B "typedef struct _TIMEINFO {"
11 .B "    time_t  time;"
12 .B "    long    usec;"
13 .B "    long    tzone;
14 .B "} TIMEINFO;"
15
16 .B "time_t"
17 .B "parsedate(text, now)"
18 .B "    char    *text;"
19 .B "    TIMEINFO        *now;"
20 .fi
21 .SH DESCRIPTION
22 .I Parsedate
23 converts many common time specifications into the number of seconds
24 since the epoch \(em
25 .IR i.e. ,
26 a
27 .IR time_t ;
28 see
29 .IR time (2).
30 .PP
31 .I Parsedate
32 returns the time, or \-1 on error.
33 .I Text
34 is a character string containing the time and date.
35 .I Now
36 is a pointer to the time that should be used for calculating relative dates.
37 If
38 .I now
39 is NULL, then
40 .I GetTimeInfo in
41 .IR libinn (3)
42 is used to obtain the current time and timezone.
43 .PP
44 The character string consists of zero or more specifications of the following
45 form:
46 .TP
47 .I time
48 A time of day, which is of the form
49 .IR hh [ :mm [ :ss ]]
50 .RI [ meridian ]
51 .RI [ zone ]
52 or
53 .IR hhmm
54 .RI [ meridian ]
55 .RI [ zone ].
56 If no meridian is specified,
57 .I hh
58 is interpreted on a 24-hour clock.
59 .TP
60 .I date
61 A specific month and day with optional year.
62 The acceptable formats are
63 .IR mm/dd [ /yy ],
64 .IR yyyy/mm/dd ,
65 .IR "monthname dd" "[, " yy ],
66 .IR "dd monthname" " [" yy "],
67 and
68 .IR "day, dd monthname yy" .
69 The default year is the current year.
70 If the year is less then 100, then 1900 is added to it; if it is
71 less then 21, then 2000 is added to it.
72 .TP
73 .I "relative time"
74 A specification relative to the current time.
75 The format is
76 .IR "number unit" ;
77 acceptable units are
78 .IR year ,
79 .IR month ,
80 .IR week ,
81 .IR day ,
82 .IR hour ,
83 .I minute
84 (or
85 .IR min ),
86 and
87 .I second
88 (or
89 .IR sec ).
90 The unit can be specified as a singular or plural, as in
91 .IR "3 weeks" .
92 .PP
93 The actual date is calculated according to the following steps.
94 First, any absolute date and/or time is processed and converted.
95 Using that time as the base, day-of-week specifications are added.
96 Next, relative specifications are used.
97 If a date or day is specified, and no absolute or relative time is given,
98 midnight is used.
99 Finally, a correction is applied so that the correct hour of the day is
100 produced after allowing for daylight savings time differences.
101 .PP
102 .I Parsedate
103 ignores case when parsing all words; unknown words are taken to be unknown
104 timezones, which are treated as GMT.
105 The names of the months and days of the week can be abbreviated to their
106 first three letters, with optional trailing period.
107 Periods are ignored in any timezone or meridian values.
108 .SH BUGS
109 .I Parsedate
110 does not accept all desirable and unambiguous constructions.
111 Semantically incorrect dates such as ``February 31'' are accepted.
112 .PP
113 Daylight savings time is always taken as a one-hour change which is wrong
114 for some places.
115 The daylight savings time correction can get confused if parsing a
116 time within an hour of when the reckoning changes, or if given a
117 partial date.
118 .SH HISTORY
119 Originally written by Steven M. Bellovin <smb@research.att.com> while
120 at the University of North Carolina at Chapel Hill and distributed
121 under the name
122 .IR getdate .
123 .PP
124 A major overhaul was done by Rich $alz <rsalz@bbn.com> and Jim Berets
125 <jberets@bbn.com> in August, 1990.
126 .PP
127 It was further revised (primarily to remove obsolete constructs and timezone
128 names) a year later by Rich (now <rsalz@osf.org>) for InterNetNews,
129 and the name was changed.
130 .de R$
131 This is revision \\$3, dated \\$4.
132 ..
133 .R$ $Id: parsedate.3 6312 2003-05-04 21:40:11Z rra $
134 .SH "SEE ALSO"
135 date(1),
136 ctime(3),
137 libinn(3),
138 time(2).