1 .\" $NetBSD: parsedate.3,v 1.15 2014/10/08 22:10:04 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
50 and an optional timezone offset (in minutes behind/west of UTC)
57 then the current time is used.
62 then the current time zone is used.
66 is a sequence of white-space separated items.
67 The white-space is optional the concatenated items are not ambiguous.
70 is equivalent to midnight today (the beginning of this day).
72 The following words have the indicated numeric meanings:
77 .Dv first, next, or one =
80 is unused so that it is not confused with
92 .Dv seventh or seven =
100 .Dv eleventh or eleven =
102 .Dv twelfth or twelve =
105 The following words are recognized in English only:
126 The days of the week:
204 A variety of unambiguous dates are recognized:
205 .Bl -tag -compact -width "20 Jun 1994"
207 For years between 69-99 we assume 1900+ and for years between 0-68
212 The year in an ISO-8601 date is always taken literally,
213 so this is the year 69, not 2069.
215 October 10, 2000; the common US format.
219 Other common abbreviations.
221 The year can be omitted.
222 This is the US month/day format.
226 .Bl -tag -compact -width 12:11:01.000012
233 Relative items are also supported:
234 .Bl -tag -compact -width "this thursday"
243 Seconds since epoch (also known as UNIX time) are also supported:
244 .Bl -tag -compact -width "@735275209"
246 Tue Apr 20 03:06:49 UTC 1993
250 returns the number of seconds passed since the Epoch, or
252 if the date could not be parsed properly.
253 A non-error result of
255 can be distinguished from an error by setting
261 and checking the value of
271 was originally written by Steven M. Bellovin while at the University
272 of North Carolina at Chapel Hill.
273 It was later tweaked by a couple of people on Usenet.
274 Completely overhauled by Rich $alz and Jim Berets in August, 1990.
278 function first appeared in
281 .Bl -tag -compact -width 1
285 function is not re-entrant or thread-safe.
289 function cannot compute days before the unix epoch (19700101).
293 function assumes years less than 0 mean -
295 years less than 70 mean 2000 +
297 years less than 100 mean 1900 +