Unfortunately, a day isn't always 24 hours

You may have noticed that the calendar in the sidebar on the right uses a nifty javascript/AJAX implementation so the page doesn't need to refresh when you go backward or forward. Yesterday I discovered a really stupid bug in it: go backward a month, then go forward to October again (unless it's already after October when you read this, in which case you just need to go back, assuming I haven't fixed the bug already). You'll see October 29th appears twice, and the days after it are shifted ahead.

How does this happen? It's because the javascript Date object doesn't have any built-in support for date arithmetic; you can't easily add a day to it for instance. So I built my own support for that. Since you can convert a date to and from a representation in seconds, to advance one day I simply add the number of seconds there's in a single day to the date object. Which worked great, until now.

You see, I'd been working under the premise that dates are all 24 hours long, not an unreasonable assumption you might think. Unfortunately, thanks to the end of Daylight Saving Time, October 29th is 25 hours long, throwing off my algorithm.

I'm going to fix this, of course. Soon, I hope.

UPDATE: It appears I'm an idiot, and the Date object does support the type of arithmetic I need. I don't see how I missed that when I implemented it... Anyway this'll make fixing it a lot easier. I still need to actually do it, of course. :)

Update 2006-10-31: The bug has been fixed. All seems well with the calendar now.

Categories: Site news
Posted on: 2006-10-30 15:22 UTC.



2013-11-22 11:29 UTC

I don't even know the way I finished up here,
but I thought this put up used to be great. I do not know who you are but definitely you're going to a well-known blogger
in the event you aren't already. Cheers!

Homöopathie Freiburg

2013-12-01 01:39 UTC

I always spent my half an hour to read this blog's content daily along with a mug
of coffee.

phenobestin 37.5

2013-12-14 02:33 UTC

Iquickly rеalizеd though tat phentermine could not be taken everyԁay.

Add to that the danger of using Phentermine for periods longer than a few weeks.
This is thee first effective weeight loss suρplement to be released
foг residentіal use.

adipex diet pills - shop at BuyPhentermine375.biz

2013-12-15 11:16 UTC

I am now аt my ideal athletic form, and don't recommend
phenterminе for anyone. The examinations or
checks adviseԁ by the doctor are ultrasound examination, which allows to cheсk the physical conduct of the child
in mothеrs' womb. Amphetamines (including Adԁerall, Vyvanse,
phentermine and dextroamphetamine) tnd tto cause decreased apppetitе
as a side effect.

martial arts supplies Continued

2014-01-31 01:04 UTC

Hello! Would you mind if I share your blog with my myspace group?
There's a lot of people that I think would really enjoy your content.

Please let me know. Thanks

kurtka delikatne ubrania

2014-02-15 13:00 UTC

Its such as you read my mind! You seem to grasp a lot about this, like you
wrote the e book in it or something. I feel that
you can do with some p.c. to power the message house
a bit, however other than that, that is wonderful blog.
A great read. I'll certainly be back.

iphone dev secrets

2014-05-10 00:56 UTC

Unquestionably believe that which you stated.
Your favorite reason seemed to be on the net the
simplest thing to be aware of. I say to you, I certainly get annoyed while
people consider worries that they just do not know
about. You managed to hit the nail upon the top and also defined out
the whole thing without having side-effects , people
can take a signal. Will probably be back to get more. Thanks

Add comment

Latest posts




RSS Subscribe