开发者

Idea of developing "Calendar" from scratch

What's the开发者_运维问答 broad math idea behind the calendar if you need to build one from scratch without depending on OS or other libraries ?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜