???
But I do handle leap years? Just not the year 2100.
1900 is in the past. It has nothing to do with my script, how it's written or whether it's a leap year. 1900 is the past, is the past, is the past. The only way you can reach it is to roll back you system clock so that your system thinks the current year is 1900 which is far beyond the use or intentions of this script. Do we modify all our scripts to accept the possibility of someone resetting the system clock to some abnormal date?
It's not a bug that it can't accept those dates? That's not what the script does. There's no argument to accept an arbitrary second date to use. You're suggesting it's a bug that the script doesn't accept something it doesn't use.
If it's necessary to appease the gods to account for the possibility of this script being used in the year 2100 I'll do it, as unrational as I think that is. To account for 1900 is just plain wrong IMHO.
I'd like to see an example of off by a day with certain combinations of current time, current date and current timezones. | [reply] |
I forgot that the birthday year doesn't matter, just the current year +- 1 matters. I was thinking more generally when you asked about (localtime)[7], not how it applied here. While the way your calculate leap years is wrong in a general sense, it is a correct simplification for the expect inputs. A comment about this wouldn't hurt. ++.
I'd like to see an example of off by a day with certain combinations of current time, current date and current timezones.
Sure, tell me on which date the time spring forwards or falls back this year Note that I only *think* your program will return an incorrect answer for some time periods due to DST, as I have said earlier. I'm not sure what the circumstances are that causes the problem, which is why I use timegm+gmtime to completely avoid the issue.
| [reply] [d/l] |
Hey ikegami
I've updated the script again (missing brackets around the leap year check). I've also added a test script to run through all dates in a year. Days from/to should progress smoothly up and down to 0 on the current date, which they do for me (but I have no DST change). If there's a DST issue, I would expect a jump in the sequence on time change day. But it may also depend on the time of day (current time) when you run the script?
| [reply] |
Updated and commented.
Fixed for the year 2100.
Fixed for feb 29 birthdays.
Also removed current day and month (which have nothing to do with the script) to avoid confusion.
(hope it still works!)
Man, that was a long road to the answer!
| [reply] |