3 ms·
The correct way to do this is to define a quadyear=365*4+1, and then just use mods & divides (quadyear -> year-within-quad -> day) with no loop, right?
by zhyder 18y ago
The correct way to do this is to define a quadyear=365*4+1, and then just use mods & divides (quadyear -> year-within-quad -> day) with no loop, right?
- marcus 18y agoNot exactly its a bit more difficult, leap years occur once every four years unless the year is divisible by 100 and not by 400 so 1900 wasn't a leap year 2000 was one 2100 won't be. Although in most places I saw the code just ignored it as something that's valid between 1901-2099 is considered good enough in most places. Edit: sorry shouldn't post this early in the morning, its 400 not 1000
- zhyder 18y agoAh, so we can maybe expect a Y2.1K problem then
- marcus 18y agoYep, but we'll have Y2K38 bug before that because of the original Unix time rep as signed 32bit int http://en.wikipedia.org/wiki/Year_2038_problem http://en.wikipedia.org/wiki/Year_2038_problem
- dwarry 18y agoNo, century years are leap years if they are divisible by 400, so 2400 will be the next such, not 3000!
- marcus 18y agoSorry, you're right. Changed the original comment.