It's That Time Again

Stefanie Diesi, Staff Engineer

It’s an early morning for many of us after “springing forward” and losing an hour of sleep over the weekend. While the time change might have a jarring impact on our alertness, our computers are probably humming along without ever noticing the switch. Or did they? It depends on which time system you’re using, since computers have many ways to track time. Here are a few of the most common:

Local Time
The time system that people are most familiar with is that displayed on your watch (or smartphone): local time. There are many complexities associated with local time, and most of them have to do with geography and politics. As you travel around, local time changes. Similarly, local time for a single geographic location can be impacted by Daylight Saving Time (DST), an adjustment applied on different days in different locations or, in some cases, not at all. Furthermore, the DST adjustment date can be changed by the government, as happened most recently in the United States in 2007. If I’m programming based on local time, I have to keep all of these factors in mind, along with the chance that rules for a given region could change any time the legislature meets, requiring a software update. For these reasons, local time is a poor way to track time internally to your product, although you’ll normally need to convert into local time for display to the user.

UTC Time
One way around this complexities of local time is to use UTC time. UTC is the time at 0° longitude and it does not vary with Daylight Savings. The conversion between local time and UTC is a simple addition or subtraction operation as long as the offset is known. In Colorado, where Cardinal Peak is located, we use Mountain Standard Time (MST) in the winter, which is UTC-07:00, and now, after our spring forward, we’re using Mountain Daylight Time (MDT), or UTC-06:00.


Time base comparison

Here’s an example of how these times are related. Since each time base has different units, the plot is not to scale, but it gives an idea of how values move with respect to one another. In this example, the machine was rebooted just after 1:39 am, and Daylight Saving Time is applied at 2:00 am.

Although UTC is not impacted by Daylight Saving, it is adjusted with the addition of leap seconds. For systems with precise timing requirements, the addition of a single second can have unintended consequences, a problem Google famously solved by applying the one-second adjustment as a series of millisecond adjustments throughout the day instead of all at once. They call this technique the “leap smear”. The addition of leap seconds is unpredictable, making it impossible to handle all future adjustments in code.

UTC is also used by the standard distributed time synchronization protocol, NTP. The subject of NTP is another blog post on its own, but simply, there are computers with very precise timing that run NTP servers. Other computers run NTP clients, which periodically receive timing updates from the NTP servers. The NTP client will then adjust the time of the host clock, either by resetting the current time or by gradually adjusting the time in small increments until the difference is corrected. Since NTP servers are corrected for leap seconds, NTP clients receive these adjustments for “free” without needing special code.

Unix Time
When even one-second adjustments are too much uncertainty for a given system, the time base of choice is often Unix time or Epoch time, which does not get adjusted for leap seconds. Unix time is defined as the time since midnight (UTC) on January 1, 1970. This value is commonly represented in seconds or milliseconds, with some applications even tracking the time in microseconds. While Unix time will drift slightly with respect to the sun as leap seconds are ignored, the overall simplicity of this time base makes it a very common choice in a wide variety of software solutions.

System Time
Another time we typically use when playing audio and video on a machine is the system time or “up-time” of the machine. This time system has the property that it is always monotonically increasing, something very important in displaying A/V streams. People generally don’t enjoy the viewing experience when the audio or video jumps backward, even for a split second. The constantly increasing feature of this time base is desirable, but the time values returned only have meaning for that specific machine. In distributed systems, the system time cannot be used for synchronization between machines because each machine will have a different up time without a standard conversion to a common time base. Also, hardware clocks drift ever so slightly; over time, this can cause noticeable disparities between different machines. Both of these limitations mean we typically convert a system timestamp on events and messages to UTC or Unix time before sharing it with other machines¾even if the timestamps are stored in system time on the local host.

There are many more options for tracking and displaying time, but this list serves as an overview of some of the most common choices. They all have advantages and disadvantages, which make them uniquely suited for different situations.

Come to think of it, maybe I’ll sleep better if I switch over to UTC or Unix time at my house before the next Daylight Saving adjustment.

Cardinal Peak
Learn more about our Audio & Video capabilities.

Dive deeper into our IoT portfolio

Take a look at the clients we have helped.

We’re always looking for top talent, check out our current openings. 

Contact Us

Please fill out the contact form below and our engineering services team will be in touch soon.

We rely on Cardinal Peak for their ability to bolster our patent licensing efforts with in-depth technical guidance. They have deep expertise and they’re easy to work with.
Diego deGarrido Sr. Manager, LSI
Cardinal Peak has a strong technology portfolio that has complemented our own expertise well. They are communicative, drive toward results quickly, and understand the appropriate level of documentation it takes to effectively convey their work. In…
Jason Damori Director of Engineering, Biamp Systems
We asked Cardinal Peak to take ownership for an important subsystem, and they completed a very high quality deliverable on time.
Matt Cowan Chief Scientific Officer, RealD
Cardinal Peak’s personnel worked side-by-side with our own engineers and engineers from other companies on several of our key projects. The Cardinal Peak staff has consistently provided a level of professionalism and technical expertise that we…
Sherisse Hawkins VP Software Development, Time Warner Cable
Cardinal Peak was a natural choice for us. They were able to develop a high-quality product, based in part on open source, and in part on intellectual property they had already developed, all for a very effective price.
Bruce Webber VP Engineering, VBrick
We completely trust Cardinal Peak to advise us on technology strategy, as well as to implement it. They are a dependable partner that ultimately makes us more competitive in the marketplace.
Brian Brown President and CEO, Decatur Electronics
The Cardinal Peak team started quickly and delivered high-quality results, and they worked really well with our own engineering team.
Charles Corbalis VP Engineering, RGB Networks
We found Cardinal Peak’s team to be very knowledgeable about embedded video delivery systems. Their ability to deliver working solutions on time—combined with excellent project management skills—helped bring success not only to the product…
Ralph Schmitt VP, Product Marketing and Engineering, Kustom Signals
Cardinal Peak has provided deep technical insights, and they’ve allowed us to complete some really hard projects quickly. We are big fans of their team.
Scott Garlington VP Engineering, xG Technology
We’ve used Cardinal Peak on several projects. They have a very capable engineering team. They’re a great resource.
Greg Read Senior Program Manager, Symmetricom
Cardinal Peak has proven to be a trusted and flexible partner who has helped Harmonic to deliver reliably on our commitments to our own customers. The team at Cardinal Peak was responsive to our needs and delivered high quality results.
Alex Derecho VP Professional Services, Harmonic
Yonder Music was an excellent collaboration with Cardinal Peak. Combining our experience with the music industry and target music market, with Cardinal Peak’s technical expertise, the product has made the mobile experience of Yonder as powerful as…
Adam Kidron founder and CEO, Yonder Music
The Cardinal Peak team played an invaluable role in helping us get our first Internet of Things product to market quickly. They were up to speed in no time and provided all of the technical expertise we lacked. They interfaced seamlessly with our i…
Kevin Leadford Vice President of Innovation, Acuity Brands Lighting
We asked Cardinal Peak to help us address a number of open items related to programming our systems in production. Their engineers have a wealth of experience in IoT and embedded fields, and they helped us quickly and diligently. I’d definitely…
Ryan Margoles Founder and CTO, notion