[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

To ease date-related calculations, the utility library has some functions
to convert a date, specified in a ClockData structure, in the number of
seconds since 00:00:00 01-Jan-78 and vice versa. To indicate the date, the
ClockData structure (in <utility/date.h>) is used.

    struct ClockData
    {
        UWORD sec;     /* seconds (0 - 59)*/
        UWORD min;     /* minutes (0 - 59) */
        UWORD hour;    /* hour (0 - 23) */
        UWORD mday;    /* day of the month (1 - 31) */
        UWORD month;   /* month of the year (1 - 12)
        UWORD year;    /* 1978 - */
        UWORD wday;    /* day of the week (0 - 6, where 0 is Sunday) */
    };

The following functions are available to operate on ClockData:

  ________________________________________________________________
 |                                                                |
 | amiga2date()  calculate the date from the specified timestamp  |
 |               (in seconds).                                    |
 |  checkdate()  check the legality of a date.                    |
 | date2amiga()  calculate the timestamp from the specified date. |
 |________________________________________________________________|

            Table 37-5: Utility Library Date Functins


amiga2date() takes a number of seconds from 01-jan-78 as argument and
fills in the supplied ClockData structure with the date and time.

checkdate() checks if the supplied clockdata structure is valid, and
returns the number of seconds from 01-Jan-78 if it is. Note that this
function currently does not take the supplied day of the week in account.

date2amiga() takes a clockdata structure as argument and returns the
number of seconds since 01-Jan-78. The supplied ClockData structure MUST
be valid, since no checking is done.

The following example shows various uses of the utility library date
functions.

     a2d.c