#### Archived

This topic is now archived and is closed to further replies.

# Which weekday is it?

This topic is 5403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am creating a boxing manager game and I need to keep a calender which works like the real gregorian calender. I have a class cDate that holds the current day, month and year and I can manipulate the date which the cDate object holds and it makes sure that the date stays valid. Now the problems is this. Let''s say that the cDate object holds the date 20th of january 1978 and I now want to know what weekday it is. Are there any algorithms for calculating the weekday or perhaps you could give me some hints how I should go making one. "Life is very short, and there''s no time for fussing and fighting my friend..."

##### Share on other sites
Couldn''t you just store the week day of the first day of play, or some irrelevent date some number of days back in time and then calculate the number of days it''s been since then, divide by seven, subtract the integral number, and multiply by seven to get the number of days after that specific weekday? The only problem would be making the algorithm support leap years, I think. But that shouldn''t be too hard.

##### Share on other sites
Yes that would be one solution, but I found another one at http://5dspace-time.org/Calendar/Algorithm.html

"Life is very short, and there''s no time for fussing and fighting my friend..."

##### Share on other sites
I'd use the boost.date_time library

[edited by - petewood on February 27, 2004 8:57:55 AM]

1. 1
2. 2
3. 3
Rutin
12
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633695
• Total Posts
3013385
×