Mail Archives: djgpp/1997/03/26/06:49:43
Everything you need is in SNIPPETS. The file PARSDATE.C contains the 
following function (the data types are declared in other headers)...
/*
**  parse_date() - Parse a date string into its components
**
**  Arguments: 1 - String to parse
**             2 - Address of year storage
**             3 - Address of month storage
**             4 - Address of day storage
**             5 - Syntax to use
**
**  Returns: 0 For success, non-zero for range errors
**
**  Notes: The following syntaxes are supported:
**
**    Date ordering: USA (month, day, year),
**                   ISO (year, month, day)
**                   EUROPE (day, month, year)
**    Delimiters:    Spaces, commas, dashes, periods, slashes. (" ,-./")
**    Years:         2-digit years assumed to be between 1970 and 2069
**                   4-digit years required otherwise
*/
Boolean_T parse_date(const char *str,
                     unsigned   *year,
                     unsigned   *month,
                     unsigned   *day,
                     Syntax_T   syntax)
This will parse your date string reliably. You then feed the dates into the 
ymd_to_scalar() function in SCALDATE.C, which converts them to scalar values 
(if you want true Julian day numbers, use ymd_to_jdnl() in JDN_L.C instead). 
The resulting long int scalar values can then be compared, days added or 
subtracted, and the resulting scalar values converted back to dates using 
the scalar_to_ymd() function in SCALDATE.C (or jdnl_to_ymd() in JDN_L.C).
- Raw text -