C Language Development Kit/Functions/GetTime
From OptiWiki
< C Language Development Kit | Functions(Redirected from C Language Development Kit/Functions/Gettime)
| Description | This function fills in the time structure with the current time as stored in the terminal's real-time clock. |
| Syntax | void gettime(struct time * timep); |
| Arguments | The structure time is defined as follows:
struct time * timep struct time { unsigned char ti_hour; // hours unsigned char ti_min; // minutes unsigned char ti_sec; // seconds }; |
| Returns | The function fills in the structure, but has no return value. |
| Remarks | The time can be set with the settime() function. |
| Example | // The following example shows the current date and time on the display. // See also the setdate() example. #include "lib.h" #include <stdio.h> void main( void ) { struct time t; struct date d; while( 1 ) { gettime( &t ); getdate( &d ); printf("\fTime: %2d:%02d:%02d", t.ti_hour, t.ti_min, t.ti_sec); printf("\nYear: %d", d.da_year); delay( 50 ); printf("\nDay : %d", d.da_day); printf("\nMon : %d", d.da_mon); delay( 50 ); } } |
