If you check this out, there is a C program that gives some clues about this.
One is to use 2 arrays, one for days in month, the other for month names. that makes it easier to look up the month name, without lots of if else clauses.
When I did this years ago, I remember there being a formula that calculated which day of the week it was given the day, month & year. It calculated the number of days since sometime in the 1700's (1752? a guess) , which was the last time that anyone meddled with the calendar. It wasn't a straight forward formula, our teachers gave it to us as part of the assignment.
I guess you could do the same thing, start from a date that you know which day it was, calc the number of days to the input date, use the % operator (modulus) to work out which day it is.
On my linux system, this is what I get for Jan 1800:
January 1800
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 |
January 1900
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 |
And Jan 2000:
January 2000
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 |
Your program will be better if it can handle a wide range of dates - you can use the jan 1900 & 2000 to see that your day of week calc works.
Hope all goes well