.\" $Revision: 6312 $ .TH PARSEDATE 3 .SH NAME parsedate \- convert time and date string to number .SH SYNOPSIS .nf .ta \w' unsigned long 'u .B "#include " .B "typedef struct _TIMEINFO {" .B " time_t time;" .B " long usec;" .B " long tzone; .B "} TIMEINFO;" .B "time_t" .B "parsedate(text, now)" .B " char *text;" .B " TIMEINFO *now;" .fi .SH DESCRIPTION .I Parsedate converts many common time specifications into the number of seconds since the epoch \(em .IR i.e. , a .IR time_t ; see .IR time (2). .PP .I Parsedate returns the time, or \-1 on error. .I Text is a character string containing the time and date. .I Now is a pointer to the time that should be used for calculating relative dates. If .I now is NULL, then .I GetTimeInfo in .IR libinn (3) is used to obtain the current time and timezone. .PP The character string consists of zero or more specifications of the following form: .TP .I time A time of day, which is of the form .IR hh [ :mm [ :ss ]] .RI [ meridian ] .RI [ zone ] or .IR hhmm .RI [ meridian ] .RI [ zone ]. If no meridian is specified, .I hh is interpreted on a 24-hour clock. .TP .I date A specific month and day with optional year. The acceptable formats are .IR mm/dd [ /yy ], .IR yyyy/mm/dd , .IR "monthname dd" "[, " yy ], .IR "dd monthname" " [" yy "], and .IR "day, dd monthname yy" . The default year is the current year. If the year is less then 100, then 1900 is added to it; if it is less then 21, then 2000 is added to it. .TP .I "relative time" A specification relative to the current time. The format is .IR "number unit" ; acceptable units are .IR year , .IR month , .IR week , .IR day , .IR hour , .I minute (or .IR min ), and .I second (or .IR sec ). The unit can be specified as a singular or plural, as in .IR "3 weeks" . .PP The actual date is calculated according to the following steps. First, any absolute date and/or time is processed and converted. Using that time as the base, day-of-week specifications are added. Next, relative specifications are used. If a date or day is specified, and no absolute or relative time is given, midnight is used. Finally, a correction is applied so that the correct hour of the day is produced after allowing for daylight savings time differences. .PP .I Parsedate ignores case when parsing all words; unknown words are taken to be unknown timezones, which are treated as GMT. The names of the months and days of the week can be abbreviated to their first three letters, with optional trailing period. Periods are ignored in any timezone or meridian values. .SH BUGS .I Parsedate does not accept all desirable and unambiguous constructions. Semantically incorrect dates such as ``February 31'' are accepted. .PP Daylight savings time is always taken as a one-hour change which is wrong for some places. The daylight savings time correction can get confused if parsing a time within an hour of when the reckoning changes, or if given a partial date. .SH HISTORY Originally written by Steven M. Bellovin while at the University of North Carolina at Chapel Hill and distributed under the name .IR getdate . .PP A major overhaul was done by Rich $alz and Jim Berets in August, 1990. .PP It was further revised (primarily to remove obsolete constructs and timezone names) a year later by Rich (now ) for InterNetNews, and the name was changed. .de R$ This is revision \\$3, dated \\$4. .. .R$ $Id: parsedate.3 6312 2003-05-04 21:40:11Z rra $ .SH "SEE ALSO" date(1), ctime(3), libinn(3), time(2).