1 .\" $NetBSD: parsedate.3,v 1.10 2010/12/22 09:12:28 wiz Exp $
3 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Christos Zoulas.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd date parsing function
41 .Fn parsedate "const char *datestr" "const time_t *time" "const int *tzoff"
45 function parses a datetime from
47 described in english relative to an optional
49 point and an optional timezone offset in seconds specified in
57 then the current time and timezone offset are used.
61 is a sequence of white-space separated items.
62 The white-space is optional the concatenated items are not ambiguous.
65 is equivalent to midnight today (the beginning of this day).
67 The following words have the indicated numeric meanings:
72 .Dv first, next, or one =
75 is unused so that it is not confused with
87 .Dv seventh or seven =
95 .Dv eleventh or eleven =
97 .Dv twelfth or twoelve =
100 The following words are recognized in English only:
121 The days of the week:
199 A variety of unambiguous dates are recognized:
200 .Bl -tag -compact -width "20 Jun 1994"
202 For years between 69-99 we assume 1900+ and for years between 0-68
207 October 10, 2000; the common US format.
211 Other common abbreviations.
213 the year can be omitted
217 .Bl -tag -compact -width 12:11:01.000012
224 Relative items are also supported:
225 .Bl -tag -compact -width "this thursday"
234 Seconds since epoch (also known as UNIX time) are also supported:
235 .Bl -tag -compact -width "@735275209"
237 Tue Apr 20 03:06:49 UTC 1993
241 returns the number of seconds passed since the Epoch, or
243 if the date could not be parsed properly.
250 was originally written by Steven M. Bellovin while at the University
251 of North Carolina at Chapel Hill.
252 It was later tweaked by a couple of people on Usenet.
253 Completely overhauled by Rich $alz and Jim Berets in August, 1990.
257 function first appeared in
260 .Bl -tag -compact -width 1
264 function is not re-entrant or thread-safe.
268 function cannot compute days before the unix epoch (19700101).
272 function assumes years less than 0 mean -
274 years less than 70 mean 2000 +
276 years less than 100 mean 1900 +