My final solution on my Date/Time/TimeZone issues.

Feb 23, 2014 16:22

Some of you may remember the fun and games I was going through trying to work out how to deal with dates, times, and timezones, between two disparate systems. If you don't, you can see the discussion thread hereI ended up actually writing out my use cases, and then working through a case by hand to see what steps were necessary where. This is ( Read more... )

Leave a comment

Comments 7

sbisson February 23 2014, 18:28:46 UTC
Silly question: why not do everything in UTC, just using the appropriate offset for display.

Reply

andrewducker February 23 2014, 19:10:31 UTC
Because if someone's told me that they want to post at 7AM tomorrow, and that their time zone is America/Toronto, then I want to treat that 7AM as being in Toronto time. So I need to translate it from being an hour (in the local timezone they happen to be in, which their browser will treat "7AM" as being) to being the same hour in what looks like UTC (so that I have a standard format for sending times across the wire) and then convert that into an Toronto time at the back end, and _then_ save it as UTC in the database.

I could say to them "Input a time for posting, in UTC", but that seems horribly user unfriendly.

Reply


cartesiandaemon February 24 2014, 09:41:39 UTC
I only skimmed it, but that seems plausible to me...

Reply

andrewducker February 24 2014, 09:45:49 UTC
Cheers!

It seems utterly ridiculous to me, but that's hardly surprising :->

Reply

cartesiandaemon February 24 2014, 10:28:06 UTC
To be clear, I didn't really examine the logic, just that when I see timezone code written by someone who knows what they're talking about, getting timezones to work properly seems to involve about that amount of fiddling, between (a) the inherent complexity and (b) fighting half-arsed standard implementations. And normally involves converting everything to UTC yourself at some point.

Reply

cartesiandaemon February 24 2014, 10:42:49 UTC
For clarity, is what you ended up doing ( ... )

Reply


Leave a comment

Up