## Day of the Week

NOTE: This function is now obsolete as the same result can be obtained by using the stringOf function as follows:

```string dayOfWeek = stringOf(Date d, "dddd")
```

Function to return the day of the week for any given date.

```
/**********************************
dayOfWeek

Returns the day of the week for any given date.
Based on Sakamoto's algorithm.
***********************************/
string dayOfWeek(Date theDate)
{
const int MONTH_TABLE[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}
const string DAYS[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }

int d = 0
int m = 0
int y = 0
int day = 0

string dateString = stringOf(theDate, "ddMMyyyy")

d = intOf(dateString[0:1])
m = intOf(dateString[2:3])
y = intOf(dateString[4:7])

if (m < 3)
{
y -= 1
}

day = (y + y/4 - y/100 + y/400 + MONTH_TABLE[m-1] + d) % 7

return(DAYS[day])
}
```

The following is an example of how to use this function:

```
Date d = "28 February 2013"
print dayOfWeek(d)
```