Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Algorithm to create a calendar?
I'm in process of creating a calendar dynamically. However, i couldn't exactly understand several algorithm on the web. for example, the algorithm from eHow.com.
Can anyone teach me the correct way (algorithm) in creating a calendar?
For now, i could understand these :
- L = Y mod 400, if L is 0, then Y is a leap year
- L = Y mod 100, if L is 0, then Y is a leap year
- L = Y mod 4 , if L is 0, then Y is a leap year
Then? what should i do?
Thanks in advance.
4 Answers
- Anonymous1 decade agoFavorite Answer
a = (14 - month) / 12
y = year - a
m = month + 12*a - 2
For Julian calendar: d = (5 + day + y + y/4 + (31*m)/12) mod 7
For Gregorian calendar: d = (day + y + y/4 - y/100 + y/400 + (31*m)/12) mod 7
for more information visit
- rowlfeLv 71 decade ago
In what language? In BASIC, there are several functions which will tell you the current date, time, day of the week, anything you want to know. You then simply do some formatting to create the calendar "table" as you please.
I am not sure about the code you have quoted. It should work out that a century IS a leap year ONLY if it is evenly divisible by 100 AND by 400. In other words, 1600 WAS, 1700, 1800, and 1900 were NOT (even though they ARE evenly divisible by 4) and 2000 WAS. I am not sure that code segment will correctly identify leap centuries and non-leap centuries. AND if you are going backwards, then you have to account for the 10 day gap which happened on the evening of October 5th, 1582. The following day was October 16th, 1582. People born after the change were automatically 10 days older than people born before the change and there were no people with birthdates for the 6th through the 15th. The church mandated this change to bring the religious holidays back into sync with the seasons. It was at this time that leap years were introduced to keep the calendar accurate, which it now IS, for a period of 3300 years until it will again be a day out of sync.
Designing the table which displays a calendar form is simply a mechanical formatting of text, which you should be able to figure out for yourself once you get the data from the system clock to tell you what "today" is as far as the system is concerned.