96 points · by neilk · 13y ago · 64 comments
Also, it should be noted which time zone a time is in. A naked date/time is about as useful as saying that you're 3 units away from me. What unit does "unit" represent? shrug
What brought on this particular use case was a JSON response where all the times were in UTC. I'm not really into forcing a technique on someone when it isn't required. If that's not your use case, then you don't have the problem!
Progressive enhancement is far better for the end user and not all that hard to implement. Some people choose to disable JavaScript, and there are compelling reasons to do this especially if, for example, you're using TBB and want to minimize your attack surface, as has been demonstrated recently.
JavaScript isn't evil by any means, and it's really important for creating cool shit, but it should never be required. If I can't use your site with scripts disabled, neither can a lot of other people. Sucks to be them though, right?
What a ridiculous statement. Lots of things are "required" if you want certain products to be useful. An XBox is required if I want to play XBox games.
Hell you require a web browser just to be able to enjoy the pleasure of checking that "disable javascript" box (though be careful you don't use Mozilla) in the first place (I mean you could use CURL but then you don't actually get to disable javascript).
The point is lets stop kidding around about Javascript here, no-javascript guy.
> If I can't use your site with scripts disabled, neither can a lot of other people.
People who need to disable Javascript are a vanishingly small portion of any potential market, there are many more use cases as far as web apps go where javascript is essential to any decent user experience. Not everything built on web technology is only about content these days. If you don't want to use that technology be my guest, but don't pretend your an important market to people developing on that technology.
> Screen readers and bots (including search engine spiders) have an easier time with well written HTML.
True but two things.
1) Web applications rarely rely on SEO outside of landing pages and a content strategy neither of which should rely on javascript for obvious reasons.
2) Designing applications for disabilities is extremely hard. Much harder than simply using "well written" HTML. Do you know how hard it is for blind people to play most video games? Again we're talking about interactive applications, not simply content. With content there is no problems but as we already went over the web is not only content now.
Edit: One more thought, technically translating the time to the local timezone setting of the browser is "progressively" enhanced. You could always just display UTC time if JS is disabled assuming that was important enough to your users to disable JS (or for bots).
2) Usually your times are stored server-side in UTC, so you never have to worry about timezones anywhere. It simplifies things a great deal. "Naked" = UTC. You assume that, whenever it's stored, it's already been translated from the user's timezone when the date was initially generated, or else the time it happened on the server was the actual time.
So far, no complaints.
Also, it'd be nice to ALERT me when my timezone has changed and give me an option to keep the old one, or use what you think my current one is.
Personaly, I think for anything where timezone is relevant, the best move is to always let the user manually enter the timezone he/she wants, or have it match the timezone of the event/service he's looking for, and of course allow for override, so changing timezone has to done client side.
I.e. if I am in Germany and search from a flight taking off from Taipei two days from now, I don't care about the departure time from the German timezone. Same thing if I reserve a restaurant in Germany while I am in Taipei, you'll want the german time for the reservation. For something internationally broadcasted showing the UTC time as default and provide a way to adapt to other timezone is OK, as the event has no local anchoring anyway.
People can do the calculation for timezones, eventually some opt to not change their phones timezone to keep in sync with other more important schedules, etc. Trying to do 'smart' things seamlessly is often just screwing with the user.
To start, it doesn't work if you use VPNs. Second, it doesn't update when you travel.
Here's one example. Even though I'm logged into Google and used Google Maps' 'pinpoint my location' feature, Google Reader is currently emailing me my daily schedule (a feature I enabled recently) in the afternoon. That's also despite my appointments being annotated with timezone information.
I call this bad engineering.
tl;dr: the timezone you use depends not just on the user and their environment, but also the event and its duration.
"Luckily, the browser already knows what timezone the user is currently in, so we can make use of the getTimezoneOffset() function"
Getting the timezone offset isn't the same as getting the timezone. Granted that in certain cases having the offset is good enough, but sometimes you need the actual timezone. In my example I needed to know when a merchant wants their pre-order to be released. For that to work predictably I needed to know their exact timezone in order to adjust the time for daylight saving properly. Remember that there are quite a few timezones that are UTC-7 and they can behave differently in regards to daylight saving.
My laptop has never changed timezone automatically. And that is a feature in my eyes.
How can you assume that just because I'm doing a weekend trip that I want my whole life to be centered around the timezone in that particular place?
Of course, it can always be turned off for others, like yourself! :)
On a phone (which also acts as a wrist watch for most people), yes. Laptop, just no.
What OS does this? And how?
I think it's pretty safe to say most people want their laptop's clock to match their local time, because how is a wrong clock useful? Of course, if you're travelling for business with complicated schedules and meetings in home times, you clearly might have different needs, but most people just want their clocks to be right.
And you certainly don't want to keep your original timezone but change the clock setting -- then just everything's wrong! :)
Phone, yes.
Laptop, yes. Times are still stored internally, and the timezone represents a localization. And if I go across the world for the weekend I see that locally, it is UTC+10, while entries in a DB are timestamped accordingly. Then I return home and I can look at the clock in my menu bar and see my local UTC-8, and all the while entries in a DB are timestamped accordingly.
I'd love to hear your use case for "if location and correct timezone can be reliably determined, it still should not be adjusted".
You can reliably tell where a cell phone is by the tower it connects to, guessing by IP is nowhere near as accurate.
Garry Tan, cofounder of posterous, said of it : "Finally, timezones in javascript done right. The world has been made a better place via this fine javascript library."
Incorrect (though usually true, I'll grant). I've often seen people with older Windows laptops (newer Windows variants, 7 and 8 certianly Vista maybe, are much better at this) that are set to display UK time but think that they are in UTC-0700. This can be fun when using file synchronisation tools... If the OS doesn't know its timezone then the browser won't either. This is a moot point when you are talking to just one user, until that user fixes their clock settings of course, but becomes a significant issue as soon as you need to coordinate timed actions between users.
Detecting the local time offset from your reference clock isn't always useful either: the machine's clock could be completely wrong so it says 01:23 where the user's wall-clock says 21:00 and your reference time matches neither.
Also some users may wish to fix your interface to a timezone other than the one currently set on the device they are currently using. Someone on holiday or on a business trip might want to keep some things linked to local time back home so they find it easier to coordinate with people there. Conversely someone currently in their home timezone might want to force your interface to match a non-local timezone for coordinating with teams/friends elsewhere in the world. You can't rely on them adjusting their clock in this circumstance as they may not be using their own machine and so might not be able to adjust the time/timezone settings (or may wish to keep them accurate to current local for other reasons).
tl;dr: Dealing with time values when there are any international concerns it harder than we tend to assume.
And depending on your app, users might want control over the timezone. When a teacher creates an assignment in canvas-lms, the due date defaults to midnight of the selected day. It would be surprising if it set it to 2am, just because the teacher happened to be traveling when the assignment was created.
To fix this I run a cron job on the ST/DT boundaries that increments or decrements stored date/times in the event calendar.
You can't infer (reliably) your exact location from a zipcode because of the reasons listed in the other comments linked to your parent comment.
Zip codes are based on postal routes, cities are not.
For example ZIP code 42223 spans Christian KY and Montgomery TN, and ZIP code 97635 spans Lake OR and Modoc CA.
Zip codes are also non-contiguous in some areas, and not bounded-polygons in others which makes them really bad for geo purposes.
When it comes to Rotten Tomatoes, I'm glad it asks my location because I prefer US film reviewers to my local film reviewers. If I let Rotten Tomatoes know my time zone, I can't access US reviewers (that I'm aware of).
Theoretically, yes. In practice, you should just use UTC.
>If you're in a corporate setting and the majority of your users are in the same time zone as your servers, then it makes sense to use that time zone.
No it doesn't. Use UTC. The Internet does not have a time zone.
>There's fewer date conversions that way.
Your library is probably "converting" the date anyway, UTC or not.
>for the other half it's a 1 hour DST conversion - which many time handling libraries have optimized
Is it really that slow to convert a date?
If you need to pick a timezone which does not observe DST, that rules out (generally speaking) most of North America and Europe and a lot of other places. So maybe you want your new time base to be Asia/Tokyo, Asia/Shanghai, Asia/Kolkata, Europe/Moscow? You're still at the whim of governments who constantly tinker with DST -- sure Europe/Moscow is "fixed" now, but it wasn't as close as 2 years ago.
To each their own, but I would not get into the business of depending on any particular zone in tzdata staying as it is currently defined for any amount of time in the future.