Last week I was lucky enough to present at JSConfAU. My talk was titled “Auto-detecting time zones in JS” (with a sub-title of “Are you a masochist?”).
Part I – Technical details
Taking a tour of terrible temporal twists and turns
A lot of the talk delved into the history of time and time zones, pointing out various oddities and things that can trip you up if you try to deal with them. I won’t repeat all of them here – partly because I doubt anyone would read the whole lot, partly because I just want to focus on the two main points I made:
1) Do you really need to store a user’s time zone preference? Or do you just need local time?
Storing a reference to a time zone ID for a particular user (then displaying time in your UI based on the zone) can be fraught with danger.
If your main aim is to just show times that are relevant for your users, get the server to output UTC and then use JS to convert the time in the browser, based on the user’s current UTC offset. This avoids knowing anything about what zone they’re in and eases maintenance significantly.
Avoiding time zone preferences also means you don’t have to worry about your users selecting their zone. The cognitive friction of choosing from a list of well over 400 defined zones is not a good user experience.
2) If you really must deal with time zones, learn from history and take the time and effort to do it properly
Sometimes you really do need to store a time zone preference. That’s fine, as long as you learn from the decades of prior knowledge in this area, and don’t try to re-invent the wheel.
Dealing with time zones is not a new problem. Despite what some members of the JS community might like to think, programming problems existed before JS, and were solved before JS.
Time zones are hard. Take the time to learn from the people who have put in a lot of effort to make them a bit easier for everyone.
The visuals of talking
Although I’ve previously put slides online for some of my SydJS presentations (the ones that actually had slides, at least), I’m not going to do that for this presentation.
Why? Well, without the context of me talking at the same time, a fair few of the slides would either make no sense or be misinterpreted. This is a view I share with Christian Heilmann, who wrote a few years ago:
The gist is: our slides are not the talks, our slides aid the talks we are giving. They are a visual catalyst for the things we talk about. When you see something and you hear about it at the same time it is more likely to stick. It is as simple as that.
[…] If I look at the PDF of a talk a few weeks later and only see pretty images without remembering what they meant at that time I get confused and frustrated.
In this instance, I’m aided by the fact that all the JSConfAU talks were recorded…
Credit where credit’s due
When slides aren’t put online, clickable links to references are lost. Handily there are these things called blog posts where one could give a simple reference list.
- A lot of the information about time zones came from the IANA time zone database (a.k.a. the Olson DB). Reading through the comments in the zone files gives a fascinating history of politically-motivated time zone changes.
- Many other pieces came from news articles on timeanddate.com, especially the article I gave fullscreen treatment to: Crimea to adopt Moscow Standard Time.
Update 2017-09-26: I’ve been advised that timeanddate.com has poor accessibility for visually-impaired users. The links listed above were the ones I mentioned in the talk, so I’ll leave them there for historical accuracy. But in the interests of providing accessible options, here are some other links for the same information:
- The map of current time zones (without daylight saving time) came from the Wikipedia article about time zones
- Stefano Maggiolo’s map of defined time versus mean solar time can be found at How much is time wrong around the world?
- The “falsehoods” blog posts I mentioned are all worth reading:
- My own attempt at visualising daylight saving rules around the world can be found at http://gilmoreorless.github.io/experiments/dataviz/dst.html (though it’s based on data from 2013 and therefore out of date already)
- The “honourable mentions” list of JS libraries that are putting good effort into trying to help with time zones:
If all you wanted from this post was technical details, read no further. The rest of the post will now be dedicated to narcissistic emotional examinations. (But that’s what blogs are for, right?)
Part II – On a personal note
I don’t know if anyone wants to know about exactly how I was feeling, but I actually gained some confidence from reading David Lewis’s post about his thoughts on public speaking a couple of months ago, so I’m writing this anyway.
I’ve never considered myself a public speaker. I was always one of those introverts who froze up and turned bright red whenever attention was turned to me, even in a small crowd of people I knew.
Over many years, I’ve tried to get more comfortable with talking in front of a group of people. Making off-hand smart-arse comments in a group of friends is one thing (and probably something I do a bit too much), but being the centre of persistent focused attention is quite another.
I first gave a tech presentation at SydJS 3 years ago. I could hear my voice shaking the whole time. It wasn’t a pleasant experience, but I’d successfully pushed myself out of my comfort zone.
Over the next few years I gave another 3 presentations at SydJS. Each time I did it, I became more and more comfortable with the idea of talking (especially in a familiar environment where I knew a majority of the people attending). But I’d still hear the shakiness creep into my voice every now and then.
So then it came to JSConf. This was my first big conference presentation and I was really fucking nervous. I knew my talk proposal had been the last one picked, so I’d only just scraped in. Plus there was the extra challenge of trying to make a talk about time zones interesting.
On the morning of the conference, I felt really, really sick, to the point where I couldn’t eat anything. My body does not handle stress well. My memory of some of talks before mine is rather fuzzy as I was trying to concentrate on breathing properly and not freaking out.
The time came to get up on stage. Lights shining at my face, hundreds of people looking up at me expectantly… and then a funny thing happened. The instant I started talking, all my stress and worries disappeared. I suddenly (and for the first time) had the absolute confidence that I knew what I was doing. Don’t ask me why.
Afterwards came the post-adrenaline slump, and the many conversations with people who recalled their own horror stories about dealing with time zones. At the post-conference party I got the ego boost of compliments from people like Brian Leroux and David Herman.
It’s taken a while, but I think I’m finally OK with the idea of public speaking. That’s not something I ever thought would happen.