39

A leap second was recently added on June 30, 2015 23:59:60 UTC.

How are leap seconds implemented in Windows (specifically Windows 7)?

3
  • 7
    Desktop computers (especially cheap ones) are notorious for having inaccurate clocks, hence the use of NTP. Turn off the NTP in Windows for a day and see how far it drifts from your cell phone (which uses NTP). You might be surprised how far off it goes.
    – Keltari
    Jul 2, 2015 at 17:03
  • 2
    @Keltari I don't think phones use NTP. The proof is that phones get the time off the mobile network automatically even if they don't have a data connection (e.g. no data plan) yet NTP would require a data connection. You could run NTP on a phone. Perhaps some without mobile network capability (phones without SIMs, or tablets) do so. But all the frequent packet exchanges for carefully measuring clock offsets in the face of latency would probably cost much more battery life than getting the clock from the mobile network, which is less accurate but plenty good enough for a phone.
    – Celada
    Jul 4, 2015 at 10:14

6 Answers 6

35

How the Windows Time service treats a leap second

The Windows Time service does not indicate the value of the Leap Indicator when the Windows Time service receives a packet that includes a leap second. (The Leap Indicator indicates whether an impending leap second is to be inserted or deleted in the last minute of the current day.) Therefore, after the leap second occurs, the NTP client that is running Windows Time service is one second faster than the actual time. This time difference is resolved at the next time synchronization.

6
  • 23
    It's not one second faster, but one second ahead. Jul 1, 2015 at 13:37
  • 20
    @ArturoTorresSánchez: One second faster and one second ahead are the same thing, at least in American English. If a clock is ahead, it is fast.
    – Yorik
    Jul 1, 2015 at 16:11
  • 17
    And in any case, "faster" is a direct quote from the linked article. So you'll need to take that up with Microsoft, not duDE. Jul 1, 2015 at 18:04
  • 11
    @GalacticCowboy, yeah, I know it's a direct quote. It just bothers me. A faster clock would get out of sync with time. Jul 1, 2015 at 19:18
  • 3
    It's just an idiom. Although I've never heard a clock that is one minute ahead being called "one minute faster", instead I hear it described as "one minute fast" all the time. Jul 2, 2015 at 16:50
35

Windows is normally acting as an NTP client. It will just get its time up to date during the next update from the NTP server, which clearly has methods of handling leap seconds. This will happen, provided your system is setup to synchronize time via NTP. If it is not, then nothing will happen as Windows 7 does not have built-in functionality to deal with leap seconds

6
  • 11
    "Windows 7 does not have built-in functionality to deal with leap seconds" - ...nor could it, since, unlike leap days, leap seconds are arbitrarily decided by some committee. Since Windows 7 can't read the future, there is no way to handle it without contacting a server. Jul 2, 2015 at 6:03
  • 27
    @BlueRaja Windows could "read the future", by using the publicly-available tzdata that contains info about future leap seconds. That's how Unix systems manage to handle leap seconds correctly. Also, NTP packets indicate when a leap second is due in the next 24 hrs. Windows 8.1 onwards does in fact use tzdata directly. Jul 2, 2015 at 6:44
  • 8
    In other words, and to answer the question directly, they are not.
    – basic6
    Jul 2, 2015 at 12:47
  • @NeilMayhew i know this is old, but Unix does not handle leap seconds "correctly"
    – PC Luddite
    Oct 15, 2023 at 18:07
  • @PCLuddite You make a good point, although it does depend on one's definition of "correctly", which is a very slippery subject. Perhaps I should have said "take account of upcoming leap seconds to keep their clocks in sync with UTC before and after they occur." However, different Unix implementations do this differently, and it varies even among Linux systems. Some pause the clock for 1s, and some spread out the difference over a 24h period by slowing the clock very slightly. However, most Unix systems do at least try to handle it. Oct 16, 2023 at 21:39
7

They are not implemented.

Just like a wristwatch, PC time-keeping is dumb. As others have mentioned, Windows 7 uses NTP to sync PC time to a known source. Which is the equivalent of you adjusting your wristwatch every now and then.

However, the leap-second does become a problem if you intend to write code that involves date/time math, where the number of seconds between two dates is important, AND where those calculations must match up with some kind of external system or data that is leap-second aware. I'm struggling to think of any such scenarios, but I imagine there are some out there.

1
4

Windows just keeps ticking along. There is no provision for leap seconds in Windows time service. It's also important to note that no major operating system has a provision for leap seconds.

At first glance, this may sound strange. If you understand what a leap second is for and when they are added, it becomes very simple.

The International Earth Rotation and Reference Systems Service monitors the earth's rotation for irregularities. Some factors alter the earth's rotation. These include tidal friction and the melting of continental ice sheets (weight changes!). In aggregate, the earth is slowing ever so slightly.

From Wikipedia:

Leap seconds are irregularly spaced because the Earth's rotation speed changes irregularly. Indeed, the Earth's rotation is quite unpredictable in the long term, which explains why leap seconds are announced only six months in advance.

Since it is irregular and announced as needed, all modern operating systems rely on Network Time Protocol (NTP) to recover from the leap second. This is such a widespread and known issue with no graceful solution that asian markets delayed their opening by five minutes to give the computers enough time to check NTP for a time update during the last leap second.

3

Microsoft doesn't care about providing super accurate time for Windows clients. They cut corners and didn't handle special cases like leap seconds for desktop clients. Fortunately, NTP servers keep better time, therefore just keep syncing!

The W32Time service is not a full-featured NTP solution that meets time-sensitive application needs and is not supported by Microsoft as such.

How the Windows Time Service Works

1

As indicated in the Windows support article Support for the leap second:

Windows Server 2019 and Windows 10 October 2018 Update do support leap seconds in the platform.

The support article also explains how earlier versions on Windows do NOT support leap seconds. In particular:

Leap second processing is not handled separately by the Windows operating system (OS). For example, year, month, date, and time information in the following format is not supported by the Windows OS:

yyyy/mm/dd 08:59:60

Therefore, 2012/7/1 08:59:60 is processed as 2012/7/1 09:00:00, per the ISO 8601 format.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .