CheckDate

Availability All terminals
Description Checks if the date structure passed to the function holds a valid date. For instance, if you specify a date of 29 February 2025, the function will return FALSE, because February only holds 28 days in a non-leap year.
All dates that are not between 1 January 2000 and 31 December 2099 will also return FALSE.
Syntax int CheckDate( struct date *datep );
Arguments
struct date *datep
Pointer to the date structure that is to be checked.
Returns
OK When the date is valid.
ERROR When the date is invalid.
Example
#include <stdio.h>
#include "lib.h"

void main( void )
{
    struct date d;

    d.da_year = 2002;
    d.da_mon = 2;
    for(;;)
    {
        d.da_day = 29; // only leap years have 29 days in February
        printf("\rDate: %02d-%02d-%04d",d.da_day,d.da_mon,d.da_year);
        if( CheckDate( &d ) == OK )
            printf("\nDate ok!!\n");
        else
            printf("\nIllegal Date!!");
        while( !kbhit() )
            Idle();
        ResetKey();

        d.da_day = 28;
        printf("\rDate: %02d-%02d-%04d",d.da_day,d.da_mon,d.da_year);
        if( CheckDate( &d ) == OK )
            printf("\nDate ok!!\n");
        else
            printf("\nIllegal Date!!");
        while( !kbhit() )
            Idle();
        ResetKey();
    }
}