GETABSDATE

Section: C Library Functions (3)
Updated: 8 February 1995
Index Return to Main Contents
 

NAME

getabsdate, prsabsdate, getindate, prsindate - date and time parsers  

SYNOPSIS

#include <sys/types.h>
#include <sys/timeb.h>

time_t getabsdate(str, now)
char *str;
struct timeb *now;

time_t getindate(str, now)
char *str;
struct timeb *now;

#include <time.h>

int prsabsdate(str, now, tm, tzp)
char *str;
struct timeb *now;
struct tm *tm;
int *tzp;

int prsindate(str, tm, tzp)
char *str;
struct tm *tm;
int *tzp;
 

DESCRIPTION

Getabsdate and getindate parse dates (in str) and convert them to time_t s (seconds since the epoch). Prsabsdate and prsindate parse dates and produce broken-out time structures and time zones instead. All are faster and smaller than get_date(3). Getindate and prsindate are faster than getabsdate and prsabsdate, but getindate and prsindate only parse Internet dates (as specified in Internet RFCs 822 and 1123).

Getabsdate and prsabsdate parse fairly arbitrary absolute dates: each date must contain a day-of-month, English month name, and two- or four-digit year, and may optionally contain a colon-separated time (with optional seconds) (defaults to 00:00:00), weekday name, and signed numeric or alphabetic time zone (defaults to local time). The day-of-month must precede the year, but no other ordering is assumed. Four-digit years are encouraged. Delimiters are space, tab, newline, slash, and comma; dashes are only delimiters if the date cannot otherwise be parsed. All-numeric dates are ambiguous and are rejected. Unknown words are assumed to be bogus timezones and are ignored. American military time zones are not supported. Alphabetic time zones other than GMT are deprecated.

Getindate and prsindate parse RFC 822 dates, as amended by RFC 1123 (GMT is strongly encouraged). These routines are intended to be used to parse dates suspected to be machine-generated or otherwise likely to be in the right format. Due to their extreme speed, they may be used as a pre-pass before calling getabsdate or prsabsdate in any case.  

SEE ALSO

ctime(3), mktime(3)
Internet RFCs 822 and 1123  

DIAGNOSTICS

All return a negative value on error.  

HISTORY

Written at the University of Toronto by Geoff Collyer and Mark Moraes (who regret ever getting involved with date parsing). Bits of code borrowed with permission from get_date(3), Rayan Zachariassen and Rich Wales. Corrections to the time zone table from Paul Eggert.  

BUGS

Getabsdate and prsabsdate modify their str arguments.

Using local time as the default time zone is okay, but it should be local time then, at the specified date and time, whereas in fact the time zone that is used is local time now. (For example, if daylight savings time is in effect when getabsdate is called, getabsdate will assume it is always in effect.) This is hard to fix without better information on time changes.

The treatment of dashes in getabsdate and prsabsdate is a hack to permit parsing of dates in DEC format (31-Jan-91), which is itself a botch, so we're even.

Alphabetic time zones are wildly ambiguous; don't use them.

The Gregorian calendar is a kludge only an innumerate could love. When will someone impose a metric calendar and free us from the vanity and incompetence of the Roman emperors, notably the random lengths of months?

Daylight savings time is a patchwork mess only a politician could love.

Weekday names are too long and redundant. Did the Norse have weak memories?

Leap years are a pain; the earth should be stabilised.


 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
DIAGNOSTICS
HISTORY
BUGS

This document was created by man2html, using the manual pages.
Time: 16:42:33 GMT, November 10, 2022