Example |
#include <stdio.h>
#include "lib.h"
const char day[][9+1] =
{
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
int WhatDayOfWeek( void )
{
int m, y, a;
struct date curr_date;
GetDate( &curr_date );
a = (14 - curr_date.da_mon ) / 12;
y = curr_date.da_year - a;
m = curr_date.da_mon + (12*a) - 2;
return((curr_date.da_day + y + (y/4) - (y/100) + (y/400) + ((31*m)/12))%7 );
}
void main( void )
{
for(;;)
{
printf("\f%s", (char*)day[ WhatDayOfWeek() ] );
Delay( 250 );
}
}
|