# MultiClock

It's weird, if you think about it, that the only fundamental unit we have to measure time is the second.

For most other stuff, we have different units we can choose from. Weight comes in kilos and pounds and stone. There are miles and furlongs and kilometers to measure distance. You can buy drinks by the pint or the liter. And so on.

Seconds are an especially strange choice because they're sexagesimal. There are sixty of them in a minute, and sixty of those in an hour. Sure, that ties back to degrees and circles (but not as cleanly as you'd think), but then when you take the next step from hours, you need twenty-four to make a day. We're stuck with a Babylonian numbering system when we're measuring the clock speed of a supercomputer or the remoteness of a distant pulsar.

It'd be a lot easier to do arithmetic in your head on time if there were a metric system alternative to seconds.

All of that stuff occurred to me a while back, and kicked off a long-running project.

If you want to binge the origin story, read this and this and this and this.

Keeping metric time

First of all, I decided to create a metric timepiece for my own use. I divided the day into ten thousand equal-sized units. That lets me count from 0000 at midnight to 9999 at the instant before the following midnight. The lowest digit in that four-digit number is one hundred microdays, or 8.64 seconds, long (there are 60 * 60 * 24, or 86,400, seconds in a day).

I bought myself some Arduino hardware and built myself a metric clock.

Keeping solar time

If you make a clock, you need to know what time zone it's in, and you need to know about daylight saving time. Both of those are kind of hard. Time zone boundaries don't run nicely along longitudinal meridians, the way they would if engineers were in charge of everything; they're squiggly and jagged and avoid running down the middle of the streets in neighborhoods, since people who live close together want to agree on what "two o'clock" means. And daylight saving time rules are made by legislatures. That's a problem.

After I got my metric clock working and paying attention to all that stuff, I wanted to leave the government behind. I decided I'd add a way to keep solar time, too.

Solar time depends on the actual location of the sun in the sky at your exact location on the face of the Earth. Solar noon happens for you when the sun is at its highest point in the sky, from your point of view. As you move west or east, that instant will change.

Inside a civil time zone, it's the same time everywhere. Noon comes for me at the same time as it does for everyone else in the time zone, even if they're many miles away. Solar noon ignores all that. It just looks up.

So a solar clock needs to know where you are. It needs to adjust for your longitude. One full revolution of the Earth takes 24 hours, and covers its full 360 longitudinal degrees. 360 divided by 24 is 15. A notional time zone is 15 degrees of longitude wide, because it takes the sun an hour to traverse 15 degrees. If fifteen degrees is an hour, then a single degree is four minutes wide. A solar clock needs to multiply your longitudinal distance from the prime meridian, where Greenwich is, by 4 to get the number of minutes to adjust.

That's not too hard. But the Earth doesn't orbit the sun in a perfect circle. It describes an ellipse. The angle between you and the sun at noon changes a little bit every day. The moment of noon shifts back and forth slowly over the course of the year. People who study the mechanics of the solar system have come up with a way to account for that shift. It's called the equation of time. That's the change you need to apply to the civil clock due to the Earth's orbital eccentricity.

I spent some time learning about that and found a way to calculate the equation of time efficiently. I use the Fourier method.

I added all of that to my metric clock, and I had a solar metric clock.

Civil time

I keep my Arduino-based solar clock on my desk. I love it, but it has a drawback. I can't really use it to schedule things with my friends. There are vanishingly few people on the planet who keep metric time, and solar time depends on where you're standing.

It still feels like a small capitulation, but I decided to add the current civil time -- the time in the current time zone, paying attention to daylight saving rules, and rendered in conventional hh:mm form -- to the clock. That way I can glance at it when setting up a Zoom meeting, but I still get that dopamine rush when solar noon ticks over at 5000 metric.

And with that, I had a civil/solar metric clock.

I made a case on my 3D printer, soldered up all the electronics nice and neat and put a smoked glass face on it. It turned out to be a pretty piece of desk furniture. Here's what it looks like:

The top row is the current metric solar time. It's 147 hundred microdays past noon -- noon's at 5000. You'll notice there's a dot after the seven. That means that the displayed time, 5147, is a prime number. I'm crazy about prime numbers and a friend of mine suggested this as an enhancement to the original clock software. I liked the idea, so did it.

The middle number is the current metric civil time. You can see that the solar time is earlier than the civil time. 5147 is less than 5558. Most of that difference is due to daylight saving time. I took the picture before we fell back in my time zone.

The bottom line is the current civil time in the normal format you're used to seeing. It's 1:20 in the afternoon.

I made a few of these clocks for friends and family. It's fun, but it's a lot of work. I have to order the electronics, print the case, solder everything up and then program it.

I had several folks ask me for clocks that I didn't have time to put together.

A civil/solar metric clock app for the iPhone and iPad

I realized I could write an app for the iPhone that did everything my Arduino clock does, and more. It's a much more powerful compute platform. There are lots of good libraries available. For a guy who learned to program in the 1970s, it's an astonishingly rich development environment, with good user interface frameworks and all kinds of toolkits.

So I did that. "Civil/Solar Metric Clock" is an inconveniently long name for display on the iPhone screen, so I decided to call the app "MultiClock."

There are two important screens in the MultiClock app. One shows civil time -- the current time where you are that everybody else uses, taking daylight saving time into account. The other shows the local solar time, based on your position and considering the current equation of time.

Each of those screens shows the time in three ways. There's a clock icon that shows the time in normal hours-and-minutes format. There's a ruler icon that shows the metric time, from 0000 (midnight) to 9999 (just before the next midnight). And there's a progress bar that shows how much of the day has elapsed. When I started using metric time, I realized you could just interpret it as a four-digit number with a decimal point in the middle and treat it as percent-of-day elapsed. So I added that display to the iOS app.

The result is a clock that lets you see what time it is in different ways.

# The time view

The clock displays the current civil time. This is the time you're used to. It takes your time zone and local daylight saving rules into account.

The current civil time is shown in both hh:mm and metric format. The clock defaults to using a 12-hour time display, though that setting will be overridden if you set your phone's clock preferences to use a 24-hour clock. You can change the MultiClock to use 12- or 24-hour formats in the Settings app on your iPhone, under the MultiClock entry. (Settings moved from the preferences tab in the app to iPhone Settings in release 2.0 of the app).

Beginning with Version 2.1, users who want to use MultiClock as a desk clock can turn on the "Keep display live" setting in Settings. This will stop the display from going dim and turning off after a short idle period. By default, this setting is off.

The Time view also shows the current solar time, in hours:minutes format and in metric format.

The current day's sunrise and sunset times are shown for both civil and solar time.

At the bottom of the display, you can see a tab bar with three items. You can tap on the items to change the display, or you can swipe left and right in order to see a different view of the MultiClock app.

# The converter view

With release 2.0, the MultiClock added a "time converter" view. This lets you enter one of the various available times -- civil or solar, hh:mm or metric -- and convert to all the others.

As discussed above, the conversion between solar and civil times depends on your location and on the position of the Earth in its orbit around the sun. The converter uses your current location for its calculation, but lets you choose the date for which you want the conversion to be done.

In order to use the converter, tap on one of the time fields (where "hh:mm" or "0000" appears in the image). You can then enter a time using the button keypad below. When you've got the time you want, hit the blue "convert" button between the times. If you've entered a time incorrectly the clock will suggest a fix. Otherwise, it will do the conversion.

If you turn off location services for the MultiClock app, you can still to hh:mm to metric time conversions, but you can't do civil to solar or solar to civil conversions. The display will show all the times it's able to compute, and will show dashes for those it's unable to compute.

You can download MultiClock from the Apple app store.

You can see the source code in the MultiClock project on my github. I've published it under a 3-clause BSD open source license.

The app doesn't collect or share any personal data. You can read the privacy policy here.

Q&A

How do you compute the equation of time?

There are lots of approximations out there! I chose this one. A group of NASA scientists made several years' worth of careful observations of the moment of solar noon and used them to plot a curve of the variation in the actual equation of time over the year. They used a Fourier transform to fit an approximate curve to those measurements. The computed value is accurate to within thirteen seconds for the duration of the twenty-first century.

After that, you're on your own.

Why isn't solar noon exactly in the middle of solar sunrise and solar sunset?

Weird, right?

It would be, except for the fact that the Earth continues on its orbit around the sun every single day. Daylight hours grow shorter or longer, depending on the season, so sunrise and sunset are shifting. Also, though, the moment of solar noon is continuously shifting. It will fall very near the midpoint of solar sunrise and solar sunset, but nearer one or the other, depending on the date.

The equation of time calculation means that solar noon is correct (to within thirteen seconds -- see above).

Why are some of the metric times shown in red?

Those are prime numbers. I am crazy about prime numbers, so decided to honor them by displaying them in red whenever they happen. You can change this behavior in the Preferences tab.

Acknowledgments

Thanks to all the users that suggested new features and enhancements from version 1.0 to 2.0! I was able to make a lot of those changes. I'm afraid I'm not able to create a useful iOS widget for the MultiClock. Several folks have asked for one. iOS doesn't have an easy way to continually update the displayed time in a widget. I'll keep thinking about workarounds, but I think that might just not be possible.

Thanks to Kate Carlson, Doug Cutting, Jennie Olson, Matt Olson and Tom White for their contributions to and use of the early Arduino version of the solar metric clock and for providing feedback on the v1.0 iOS app.

William Vambenepe helped with some interesting history of metric timekeeping.

Chris Deppe helped plumb the mysteries of the Xcode UI and did a very helpful code review prior to launch.

Chris Howell wrote the excellent Solar library I use to get sunrise and sunset times.

Larry Rotters proposed the "Keep display live" feature and was patient and helpful in testing early implementations.

Teresa has put up with my nerd obsessions cheerfully ever since we met. I probably could have bought a Rolex for the money I spent in the Arduino ecosystem over the course of a year. She never said a word! I'm a lucky guy.