SetDateTime

Availability >All terminals
Description SetDateTime() sets the date and time in the terminal's real-time clock to the date in the date structure and the time in the time structure.
Syntax int SetDateTime( struct date *datep, struct time *timep );
Arguments
struct date *datep
The date structure is defined as follows:
struct date
{
    unsigned int da_year;   // current year, 4 digits
    unsigned char da_day;   // day of the month
    unsigned char da_mon;   // month; 1 = January
};
struct time *timep
The time structure is defined as follows:
struct time
{
    unsigned char ti_hour;  // hours
    unsigned char ti_min;   // minutes
    unsigned char ti_sec;   // seconds
};
Returns
OK Date and time were valid and successfully set.
ERROR Date and time were invalid.
Remarks This function can be used to set the date and time in a single function call, without calling both SetDate() and SetTime().
Example
// SetDateTime() / GetDateTime() example

#include <stdio.h>
#include "lib.h"

void main( void )
{
    struct date d = { .da_day = 3, .da_mon = 11, .da_year = 2028 };
    struct time t = { .ti_hour = 8, .ti_min = 9, .ti_sec = 42 };

    SetDateTime( &d,  &t );

    for(;;)
    {
        GetDateTime( &d, &t );
        printf("\n%02d:%02d:%02d", t.ti_hour, t.ti_min, t.ti_sec);
        printf(" %02d/%02d/%04d", d.da_day, d.da_mon, d.da_year);
        Delay( 50 );
    }
}