views:

47

answers:

2

What's the broad math idea behind the calendar if you need to build one from scratch without depending on OS or other libraries ?

A: 

I dont see any real math involved when building a calendar. Of course there is the problem of leap years, but this is no complex math, just applying the rule that there is one more day each four year, and this extra day is skipped every 100 years.

You do the math!

Btw, I think you're always dependent on OS since the OS provides you the current date and time. If you really want to be OS independent you have to get the current date and time from the BIOS.

Henri
+3  A: 

The broad math idea is finding out the day of the week for a specific day. Every time you print out a month, you must pick up the first day of that month an start from the right week/day. Like usual wikipedia has the answer:

http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week

Also you will have to take into account leap years to make sure you print February properly.

Francisco Garcia