C Language Development Kit/Functions/GetTime

From OptiWiki

< C Language Development Kit | Functions
Revision as of 11:32, 25 February 2009 by Jbo (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Description This function fills in the time structure with the current time as stored in the terminal's real-time clock.
void gettime(struct time * timep);
struct time * timep
The structure time is defined as follows:
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.
// 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 );

Personal tools