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

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

  • 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 '15 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 '15 at 10:14
up vote 36 down vote accepted

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.

  • 23
    It's not one second faster, but one second ahead. – Arturo Torres Sánchez Jul 1 '15 at 13:37
  • 1
    @ArturoTorresSánchez Depends on whether the leap second is being added or removed. It is possible that the writer of this text had a negative leap second in mind. Negative leap seconds have not happened yet, but they are possible and presumably supported by ntp. – Pepijn Schmitz Jul 1 '15 at 15:53
  • 19
    @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 '15 at 16:11
  • 16
    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. – GalacticCowboy Jul 1 '15 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. – Arturo Torres Sánchez Jul 1 '15 at 19:18

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

  • 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. – BlueRaja - Danny Pflughoeft Jul 2 '15 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. – Neil Mayhew Jul 2 '15 at 6:44
  • 8
    In other words, and to answer the question directly, they are not. – basic6 Jul 2 '15 at 12:47

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.

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.

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

protected by Community Aug 5 '15 at 16:50

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.