C Language Development Kit/Functions/CheckTime

From OptiWiki

Jump to: navigation, search
Description Checks if the time structure passed to the function holds a valid time. For instance, if you specify 61 minutes past 2, the function will return FALSE.
Syntax
int checktime(struct time * timep);
Arguments
struct time * timep
Pointer to the time structure that is to be checked.
Returns
OK When the time is valid.
ERROR When the time is invalid.
Example
#include "lib.h"
#include <stdio.h>
 
void main( void )
{
    struct time t;
 
    t.ti_hour = 12;
    t.ti_min = 12;
    while( 1 )
    {
        t.ti_sec = 62;
        if( checktime( &t ) == OK )
            printf("\fTime ok!!\n");
        else
            printf("\fIllegal time!!");
        while( !kbhit() )
            idle();
        resetkey();
 
        t.ti_sec = 12;
        if( checktime( &t ) == OK )
            printf("\fTime ok!!\n");
        else
            printf("\fIllegal time!!");
        while( !kbhit() )
            idle();
        resetkey();
    }
}


Views
Personal tools