Skip to content

What time is it here?

Sometimes things that seem simple wind up being fairly complex. One of the things that makes designing and prototyping so interesting is realizing how little you know about things you take for granted. For instance, what time is it where you are? How do you know what time it is and what actually determines the canonical time for a given location?

We’ve been working on a little project for a device knows what time it is without needing to connect to wi-fi or a cell network. Why no connection? We think there are some devices that don’t need to be fully connected to a network to be clever.

If a connected device moves around, finding and accessing wi-fi becomes annoying and cell networks are expensive, outrageously so if you take the device on an international trip. Fortunately there’s a better way that doesn’t require anything other than access to a data source that you’ve almost certainly used before: GPS. Satellites broadcast out GPS data packages called “sentences” to anything listening. For instance:

$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70

Here’s a breakdown of the above “sentence”:

GZDA

So we know the time, right? Well, sort of. We know UTC which is the time in Greenwich, UK, which helps if we’re in the UK and not if we’re not because of timezones. It’s pretty easy to use longitude to a very rough estimation of time, something like:

int tzOffset = (longIsEast?1:-1) * GPS.long * 24 / 360;

And that’s maybe sort of mostly okay but Not The Right Way To Do It.