Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Is your code ready for the leap year?

03 Feb 2016   #1

64-bit Windows 10 Pro
Is your code ready for the leap year?

As we enter February, it's a good time to remember that 2016 is a leap year. For most people, this may just be an interesting oddity; an extra day to work or play. But for software developers, the leap year can cause significant pain.

If you are just now thinking about checking your code for leap year bugs, you better move quickly. In fact, you might already be experiencing the effects and may not even realize it! What kind of bugs might be lurking in your code?
  • Off-by-one issues, especially around data filtering using date-range queries
  • Unexpected or undesired behavior in user interfaces
  • Potential for exceptions, crashes, or hanging as edge cases are encountered
“Meh,” you say. “My code is just fine. We have unit tests.”

“Oh really,” I say. “Do your tests properly mock the clock? Do they test edge cases including February 29 and December 31? Have you tested any low-level C++ code you might have as well as the rest of your system? Do you even know what a leap year bug looks like?”

Most often, blank stares.

Why does this matter for Azure?

Well really, it applies to just about any code a developer might write, and quite a lot of it may end up running in the Azure cloud! Azure had a leap year outage of its own in 2012, and we've been working hard to ensure a smooth experience this time around. We'd like all of our customers to benefit from our research and experiences since then.

Ok, so what do I need to know?

There's a lot to cover here, so let's start with the most important things first.
  • February 29 is not the only day affected by the leap year. Another very important date is December 31, because it is the 366th day of the year and many applications mistakenly hard-code a year as 365 days.
    • With particular consideration for the cloud, also consider the vast majority of cloud applications use UTC (Coordinated Universal Time), or at least, they should. That means at midnight on February 29, it may actually be some other time in your local time zone. For example, in the US Pacific time zone, the leap day will hit UTC when it is 4:00 PM on February 28 (the previous day on the calendar). Check times in other time zones.
    • If you are preparing to monitor your system in real-time for leap day issues, you should be considering the three-day window from February 28 through March 1. Likewise, you should watch out for day 366 issues from December 30 through January 1.
  • Leap year bugs can be found anywhere, in any language, but are most dangerous in C / C++ code, where they can cause application crashes or buffer overflows (which are a security risk).
  • Past leap years have included some high-impact, high-profile bugs, such as:
These are just the big stories that made news headlines. I'm sure thousands more occurred with varying degrees of impact and noticeability. Another lesser-known leap year bug from 1996 actually caused process control systems at aluminum smelting plants in New Zealand and Tasmania to shut down abruptly at the stroke of midnight on December 31 (the 366th day).

This resulted in millions of dollars in damage to equipment as temperatures of molten metal went unregulated. Stories from yesteryear like this one remind me of the real-world dangers of software glitches. Considering the recent widespread adoption of IOT and its intersection with cloud computing, we should all be on high alert...

Read more: Is your code ready for the leap year? | Microsoft Azure Blog

My System SpecsSystem Spec

 Is your code ready for the leap year?

Thread Tools

Similar help and support threads
Thread Forum
Windows 7 suddenly not genuine after a year, error code 0xC004F200
Yesterday I was browsing on the internet like I usually do, when suddenly my desktop screen turned black and some white text appeared above the clock in the botom right-hand corner saying "This copy of Windows is not genuine." I also get a message every time I log in saying that I may be using a...
Windows Updates & Activation
This year's Y2K: 'Leap second' threatens to break the Internet
More: This year's Y2K: 'Leap second' threatens to break the Internet - Jan. 13, 2015 Original IERS bulletin:
Should I take the leap?
Hello guys, sorry for the inactivty, business is booming :) Even though I've always said that I would never upgrade to Windows 8 I am thinking of it. Why? Well, to be honest - I don't know myself. I am wondering whether or not Win7 64bit programs run on Win8. I haven't really done the...
Windows Updates & Activation
W7 Leap Authenication
Well I have been trying to get the wireless setup on the computer at work. We use Cisco LEAP to secure it, now I can get the system to see the network and try to connect but each time it kicks back asking for username and password. I put in the information and yet it still doesnt work. We...
Network & Sharing
Nine year old writes iPhone code
Here's something for you iPhone users. BBC NEWS | Technology | Nine-year-old writes iPhone code
Chillout Room

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 22:32.
Twitter Facebook Google+