WhatDayOfWeek

Description Return an integer value representing the current day of the week. Starting with Sunday as 0.
Syntax int WhatDayOfWeek( void );
Arguments none
Returns Integer value representing the current day of the week.

0 Sunday
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saterday
Remarks None
Example
#include <stdio.h>
#include "lib.h"

//
// Array with the names of the days of the week
//
const char day[][9+1] =
{
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
};

// Returns the current day of the week
// 0 = sunday, 1 = monday, 2 = tuesday, 3 = wednesday
// 4 = thursday, 5 = friday, 6 = 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 ); // wait 5 seconds before update
    }
}