timezones… working… at last
A few days ago my now good friend PJ informed me that he wasn’t getting his text reminders on time. Sure enough the time zone calculations on the site were messed up. What was happening is this… Let’s say you were 2 hours behind (GMT-5). That would make you (GMT-7). Well, since the web sites server is on (GMT-5), the site is supposed to add 2 hours to the send time. So if you live in (GMT-7), and setup a reminder for 8am EST, your reminder would be sent at 10am (GMT-5), which is the same thing as 8am (GMT-7).
I’ll spare you the details, but basically I got the whole thing mixed up. If you were (GMT-7), and the site should have added 2 hours to your send time, it subtracted 2 hours. Likewise if you are (GMT-3), it added 2 hours.
How did something like this happen? Well, the quick answer is, “inability to test throughly”. But the more accurate answer is, “there are some complex things going on behind the scenes”. First off, we’re not dealing with 12 hour time, which I’m used to. We’re dealing in 24 hour time. Secondly, everything is based off (GMT-5), because that’s where the server is sending from. Next, I’m not dealing in hours, I’m dealing in seconds, because that’s how PHP works.
So instead of just subtracting 6 hours from GMT to get Central Time, I’m actually adding 3600 seconds. Confusing, right?
Lastly, when I started building the site, I didn’t take timezones into consideration, so it never occured to me that offsetting the number of hours of a reminder could actually result in the change of a day. Let’s say that the sites server is in (GMT-5), but you’re on the other side of the world, in (GMT+10). Well, if you setup a reminder for 10pm (really 22:00), the site is going to take whatever time you input (22:00) and add 17 hours (-5 +12 = +5… +5+5 = +10). Well, adding 17 hours is going to change the day. Which I didn’t anticipate at first. So now I actually had to go back into the database and change the datatype - which meant I had to go though all the sites core functionality and change it to work with a different datatype.
yuck.
At the end of the day, it took me a solid 6 hours to finish everything. The downside is that previous reminders on any timezones besides (GMT-5) will need to be recreated so they calculate the correct timezone offset. It really isn’t that big a deal, as only a few users are on a different timezone right now, but still, it’s annoying for them…
They’re also going to have to suffer with some inaccurate presenting of time when they’re managing the reminders. This should be fixed pretty quickly, but it can cause confusion for the time being. Sorry about that.
I want to sleep, and i don’t want to dream. Dreaming means thinking, and the very last thing I want to do right now is think.
g’night everyone
