[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