[alt.sources.wanted] improved version of "getdate"?

kak@hico2.UUCP (Kris A. Kugel) (03/18/91)

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.

Does anybody have new/current info on this?

                               Kris A. Kugel
                             ( 908 ) 842-2707
                      uunet!tsdiag.ccur.com!hico2!kak
                        {daver,ditka,zorch}!hico2!kak
                      internet: kak@hico2.westmark.com

moraes@cs.toronto.edu (Mark Moraes) (03/23/91)

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.