


     DATE(3)                       (UCLA)                      DATE(3)



     NAME
          parsedate - interpret character strings representing dates

     SYNOPSIS
          #include "parsedate.h"

          char date;
          struct parsedate *pd;

          pd = parsedate (date);

          compute_unixtime (pd);

          break_down_unixtime (pd);

          date = mail_date_string (pd);

          date = uucp_date_string (pd);

     DESCRIPTION
          These routines manipulate character strings representing
          dates.  parsedate returns a pointer to a structure of the
          following form (described in the include-file parsedate.h):

          struct parsedate {
               long unixtime;      /* as returned by time(2) */
               char *error;        /* non-NULL = error */
               int year;           /* year (1600 on) */
               int month;          /* month (1-12) */
               int day;            /* day of month (1-31) */
               int hour;           /* hour (0-23) */
               int minute;         /* minute (0-59) */
               int second;         /* second (0-59) */
               int zone;           /* time zone offset */
               int dst;            /* daylight savings time */
               int weekday;        /* real day of week */
               int c_weekday;      /* claimed day of week */
          };

          Any field containing the value -1 (except for error)
          indicates information which was either not supplied or was
          invalid.

          unixtime is the UNIX internal representation of the date
          (i.e., number of seconds since 1970).  error is NULL if the
          date string did not contain a syntax error; otherwise, it
          points to the position in the date string where a syntax
          error was discovered.  zone indicates the time-zone offset
          in minutes from UTC.  A positive value denotes a time zone
          east of Greenwich; a negative value denotes a zone west of
          Greenwich.  dst is equal to 1 if the indicated time zone
          denotes ``daylight savings time'', or 0 if daylight savings



     Hewlett-Packard               - 1 -             (printed 3/14/85)






     DATE(3)                       (UCLA)                      DATE(3)



          time is not indicated.

          weekday and c_weekday indicate a day of the week via a value
          in the range 0-6 (0 = Sunday, 6 = Saturday).  c_weekday
          shows which day of the week was actually specified in the
          date string; weekday is derived from year, month, and day
          via a perpetual-calendar algorithm.

          compute_unixtime takes a struct parsedate in which the year,
          month, day, hour, minute, second, and zone fields have been
          filled in, and fills in the unixtime and weekday fields as
          appropriate.

          break_down_unixtime takes a struct parsedate in which the
          unixtime and zone fields have been filled in, and fills in
          the year, month, day, hour, minute, second, and weekday
          fields as appropriate.

          mail_date_string returns a pointer to a RFC822 (ARPANET mail
          standard) format character string corresponding to a struct
          parsedate.  Similarly, uucp_date_string returns a pointer to
          a UUCP-mail format character string corresponding to a
          struct parsedate.  In each case, the year, month, day, hour,
          minute, second, and zone fields should be set first.  If
          only the unixtime and zone values are initially avaiable,
          then break_down_unixtime should be called before trying to
          generate a date string.

     DIAGNOSTICS
          If the character string supplied as an argument to parsedate
          contains a syntax error, the error variables in the returned
          struct parsedate will be set to point to the place in the
          argument string where the error was discovered.

          Any field which is either unspecified or given an invalid
          value in a call to parsedate is set to -1.  compute_unixtime
          and break_down_unixtime also set the appropriate fields to
          -1 if they are unable to compute the requested values.

          mail_date_string and uucp_date_string return NULL if the
          information required to generate the date string is missing
          or invalid.

     BUGS
          The returned value from a call to parsedate,
          mail_date_string, or uucp_date_string points to a static
          area whose contents will be overwritten by the next call to
          the same routine.

          A time-zone offset of ``-0001'' (i.e., one minute west of
          Greenwich) results in a zone value of -1, and is thus
          indistinguishable from an invalid or missing time zone.



     Hewlett-Packard               - 2 -             (printed 3/14/85)






     DATE(3)                       (UCLA)                      DATE(3)



          Since this particular time-zone offset is not (and almost
          certainly never will be) used anywhere in the world, the
          fact that it cannot be distinguished from an invalid or
          missing value is probably unimportant.

     AUTHOR
          Richard B. Wales
          UCLA Center for Experimental Computer Science















































     Hewlett-Packard               - 3 -             (printed 3/14/85)



