#075: It's Time

There are a few things that, as a programmer, will get under your skin immediately. One of those is the topic of time, and especially time zones. Ask any programmer about them, and you can see the frustration in their faces immediately.

At first glance, it’s not obvious why. After all, it seems to be fairly straightforward: You have a clock to tell you the time, and there are 60 seconds in a minute, 60 minutes in an hour, 24 hours in a day, and 7 days in a week. When it comes to months it’s a bit more complicated (it’s either 30 or 31, except February, which has 28 days), and with years, you have to be careful about leap years, but isn’t that what we have computers for, after all?

Except it’s not. As programmers have to not only deal with the usual cases, but (eventually) also all of the edge cases, they will tell you that:

And it gets even more confusing once you add dates into the mix. Depending on where you live, 2018/09/01 is either January 9th, or September 1st (in the US, dates are commonly written as “Year, Day, Month”, not “Year, Month, Day”).

So it’s no surprise we have bugs like iPhone alarms not going off on New Year’s.

That last point probably needs some explaining, though. How can a second be longer than a minute?

Most clocks (especially those in computers) are very inaccurate, and can’t actually keep time all that well. Which is why there’s a protocol called NTP whose sole purpose is to allow computer clocks to be synchronised with (very accurate) atomic clocks. Usually, this happens so often, you don’t notice that your clock was even off by more than a second, and in order to not confuse the software its running, the operating system introduces drift into its clock, so a second can be a bit longer or shorter than an actual second, until the system time is in sync again with the atomic clock. But sometimes, the system clock can be very far behind, or ahead — and then, depending on how its configured, the operating system can stretch out seconds or minutes in order to get back in sync.

There’s an even simpler case where this can happen: If you start a timer on your laptop, then put it to sleep, and then wake it up an hour later, what should the timer read? There’s an argument for both cases: One where the timer displays the time that has passed for us since it’s been started (ie. around one hour of elapsed time), or the one where it only counts the time it was actually able to run: Probably less than a minute.

Even GPS Satellites aren’t save from time shenanigans. They have atomic clocks on board, so they can emit the accurate signals you need to calculate your position down to a meter. But since they are in orbit, those calculations have to take Einstein’s relativity theories into account, since the clocks on those satellites seem to tick faster from our viewpoint down here on Earth. No, really: special relativity tells us that since the satellites move very fast, their clocks should appear to tick slower, but since they are also very high up, and thus farther away from Earth’s large mass, general relativity tells us that those clocks should appear to tick faster than on Earth’s surface. Add these two together, and the result is that the GPS satellite’s clocks gain about 40 microseconds each day — enough so that without accounting for this, it would add an error of about 10km per day to position calculations.

Take all of this together, and it’s easy to see why so many programmers are fan of Doctor Who, whose time-traveling protagonist once described time as wibbly-wobbly timey-wimey stuff (YouTube).

Next week: Why time zones are even worse.

Facebook

Yes, social media again. First, while more and more people are reporting to use Facebook less, or even completely quit the site, Facebook reports steady daily active user numbers. Bloomberg’s Leonid Bershidsky dives into why Facebook’s Numbers and Polls of Its Users Tell Different Stories. Meanwhile, Tim Wu argues that Facebook, along with the other Silicon Valley giants, has become too big for our collective good, and argues it’s time to break up Facebook.

Looks Can Be Deceiving

Beautiful things are nice to look at. A coffee pot from a Swedish design company has a certain aesthetic, and most likely looks great on the table. But that doesn’t make it into a useful coffee pot. Jason Fried on the difference between in-store good vs. At-home good.

Lies, Lies, Lies

If you’ve ever wondered why Trump and Putin can get away with such obvious lies, well, it’s not just that they don’t care about the truth: It’s about power. Why obvious lies make great propaganda (YouTube)

📖 Weekly Longread 📚

Vice Media Was Built on a Bluff

🦄 Unicorn Chaser 🦄

Winners of the 2018 National Geographic Travel Photographer of the Year Contest