# Leap Smear

Since 2008, instead of applying leap seconds to our servers using clock steps,
we have "smeared" the extra second across the hours before and after each leap.
The leap smear applies to all Google services, including all our APIs.

## Our proposed standard smear

Many organizations use smeared clocks, and it would be helpful if the smears
were the same. After all, the purpose of clocks is to read the same time in
different places.

We encourage anyone smearing leap seconds to use a **24-hour linear smear from
noon to noon UTC**.

This smear combines the features that experience has shown to work well for many
distributed computing applications:

- The long duration keeps the frequency change small. The change for the smear is about 11.6 ppm. This is within the manufacturing and thermal errors of most machines' quartz oscillators, and well under NTP's 500 ppm maximum slew rate.
- Centering the smear on the leap second, instead of having it begin or end at the leap second, minimizes the maximum offset.
- Compared to a cosine smear, the linear smear is simpler, easier to calculate, and minimizes the maximum frequency change.
- The 24-hour duration has been widely adopted by others implementing smears. We previously used a 20-hour smear duration, but changed to align with this more popular noon-to-noon interval.

We plan to use this smear for all future leap seconds. Amazon
[uses this smear](https://aws.amazon.com/blogs/aws/look-before-you-leap-the-coming-leap-second-and-aws/)
in AWS. One way to use it in your systems is to configure them to use
[Google Public NTP](https://developers.google.com/time/guides).

## Example of the standard smear

In this example, we will suppose there is a leap second at the end of December
2022, although the actual schedule has not yet been announced.

The smear period starts at [2022-12-31 12:00:00
UTC](https://www.timeanddate.com/worldclock/converter.html?iso=20211231T120000&p1=1440&p2=1241)
and continues through [2023-01-01 12:00:00
UTC](https://www.timeanddate.com/worldclock/converter.html?iso=20220101T120000&p1=1440&p2=1241).
Before and after this period, smeared clocks and time service agree with clocks
that apply leap seconds.

During the smear, clocks run slightly slower than usual. Each second of time in
the smeared timescale is about 11.6 μs longer than an [SI
second](http://www.bipm.org/en/publications/si-brochure/second.html) as realized
in [Terrestrial Time](https://en.wikipedia.org/wiki/Terrestrial_Time).

At the beginning of the leap second, smeared time is just under 0.5 s
behind UTC. UTC inserts an additional second, while smeared time continues
uninterrupted. This causes smeared time to become just under 0.5 s ahead
of UTC when the leap second ends.

By continuing to run the clocks at the same slowed rate, the ongoing smear
reduces this offset over the next twelve hours. By 12:00:00, smeared and leaping
clocks agree again.

| TAI | Unsmeared UTC | Smeared time |
|---|---|---|
| 2022-12-31 12:00:36.000000 | 2022-12-31 11:59:59.000000 | 2022-12-31 11:59:59.000000 |
| 2022-12-31 12:00:37.000000 | 2022-12-31 12:00:00.000000 | 2022-12-31 12:00:00.000000 |
| 2022-12-31 12:00:38.000011 | 2022-12-31 12:00:01.000011 | 2022-12-31 12:00:01.000000 |
| 2023-01-01 00:00:35.499976 | 2022-12-31 23:59:58.499976 | 2022-12-31 23:59:58.000000 |
| 2023-01-01 00:00:36.499988 | 2022-12-31 23:59:59.499988 | 2022-12-31 23:59:59.000000 |
| 2023-01-01 00:00:37.000000 | 2022-12-31 23:59:60.000000 | 2022-12-31 23:59:59.500005 |
| 2023-01-01 00:00:37.500000 | 2022-12-31 23:59:60.500000 | 2023-01-01 00:00:00.000000 |
| 2023-01-01 00:00:38.000000 | 2023-01-01 00:00:00.000000 | 2023-01-01 00:00:00.499994 |
| 2023-01-01 00:00:38.500011 | 2023-01-01 00:00:00.500011 | 2023-01-01 00:00:01.000000 |
| 2023-01-01 00:00:39.500023 | 2023-01-01 00:00:01.500023 | 2023-01-01 00:00:02.000000 |
| 2023-01-01 12:00:36.999988 | 2023-01-01 11:59:58.999988 | 2023-01-01 11:59:59.000000 |
| 2023-01-01 12:00:38.000000 | 2023-01-01 12:00:00.000000 | 2023-01-01 12:00:00.000000 |
| 2023-01-01 12:00:39.000000 | 2023-01-01 12:00:01.000000 | 2023-01-01 12:00:01.000000 |

Over the 86,401 SI seconds of the smear, the stretch in the 86,400 indicated
seconds adds up to the one additional SI second required by the leap.

A negative leap second, if one were ever to occur, would be smeared by speeding
up clocks over the 86,399 SI seconds from noon to noon.

## Other smears

Several other smears have been proposed or implemented.

- [UTC-SLS](https://www.cl.cam.ac.uk/%7Emgk25/time/utc-sls/) is a linear smear over 1,000 s before the leap (23:43:20 to 00:00:00).
- [Google's 2008
  smear](https://googleblog.blogspot.com/2011/09/time-technology-and-leaping-seconds.html) was a 20-hour cosine smear before the leap (04:00:00 to 00:00:00). This was the only time we used a cosine smear.
- [Google's second leap
  smear](https://cloudplatform.googleblog.com/2015/05/Got-a-second-A-leap-second-that-is-Be-ready-for-June-30th.html) was a 20-hour linear smear centered on the leap. We used this in 2012, 2015, and 2016.
- [Bloomberg's
  smear](https://data.bloomberglp.com/professional/sites/4/Bloomberg-Leap-Second_December-2016.pdf) is a linear smear over 2,000 s after the leap (00:00:00 to 00:33:20).
- [Meinberg](https://www.meinbergglobal.com/download/burnicki/Leap%20Second%20Smearing%20With%20NTP.pdf) has implemented a cosine smear of configurable duration.

## Software support for the smear

Our open source [unsmear library](https://github.com/google/unsmear) will
convert in either direction between smeared time and unsmeared TAI or GPST.