moraes@cs.toronto.edu (Mark Moraes) (03/25/91)
Archive-name: unix/library/libdate/1991-03-23 Archive: ftp.cs.toronto.edu:/pub/libdate.shar.Z [128.100.3.6] Original-posting-by: moraes@cs.toronto.edu (Mark Moraes) Original-subject: Re: improved version of "getdate"? Reposted-by: emv@msen.com (Edward Vielmetti, MSEN) In comp.sources.wanted you write: >I recently saw a mention of an improved version of the "getdate" >routine. (The article disappeared in a semi-daily emergency >disk clean). I want to use a routine like this for general usage. >I've got the 1986 one, and either I'm using it wrong, >or it can't read date(1) format dates, which limits its usefulness. The latest set of patches to C News include a general date parser that will, among other things, parse date(1) format. Also a very fast RFC822/1123 date parser. Even the general date parser is considerably faster than getdate (a factor of 3 to 4). (If size is a concern to you, it's also somewhat smaller) You can get just the date parsing package (with a small test program and a simple regression test) as pub/libdate.shar.Z from ftp.cs.toronto.edu. The second part of the 3-part C News patch being posted this week (<1991Mar20.224941.19240@zoo.toronto.edu> in news.software.b, pub/c-news/patches/17-Mar-1991 on ftp.cs.toronto.edu) also contains all the relevant files and manual pages if you already have C News. Please remember to wait for the next part before recompiling C News! Once the current C patch is complete, pub/libc.c-news.shar.Z (the programming workbench no-one should leave home without!) will be updated to contain this stuff. The files you need are: libc/dateconv.c libc/dateconv.h libc/datetok.c libc/datetok.h libc/getabsdate.3 libc/getabsdate.c libc/getindate.c libc/qmktime.c libc/split.3 libc/split.c People running System V will need libusg/ftime.c hfake/sys/timeb.h They're all standalone and don't require other parts of the C News distribution. Other features of getabsdate: + does not accept all-numeric dates. Yes, this is a feature -- it avoids the irritating ambiguities (1/2/90) which will only get worse when 2000 rolls around (1/2/3?) + has an interface to return a struct tm with the parsed components instead of a time_t. + has a simple rule for avoiding ambiguities between two digit years and days -- the day must come first. Otherwise, it is far less rigid than getdate since it imposes no other ordering, and will ignore weird text, assuming it to be unknown timezones. + more complete timezone info. [It has been pointed out that the timezone table has several obsolete zones and some errors -- to be fixed in the next C News patch] + isn't written in yacc, doesn't use lex. + will parse C News patchfile names and DEC dates :-) One shortcoming: it lacks a relative date parser. [getreldate() will hopefully be ready in time for the next C News patch] Mark.