Availability | All terminals | ||||
Description | This function fills in the date structure and time structure with the current date and time stored in the terminal's real-time clock. | ||||
Syntax | short GetDateTime( struct date *datep, struct time *timep ); | ||||
Arguments |
struct date *datepThe 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 *timepThe time structure is defined as follows:struct time { unsigned char ti_hour; // hours unsigned char ti_min; // minutes unsigned char ti_sec; // seconds }; |
||||
Returns |
|
||||
Remarks | This function can be used to retrieve the date and time in a single function call, without calling both GetDate() and GetTime(). | ||||
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 ); } } |