DevDisasters

Trans-Atlantic Time Trap

Nobody believed the French. Not the entire country, or Frenchmen in general, but rather the folks who worked at the European Branch Office in Paris. The bug they described-their computer's internal date was randomly changing-reeked of user error and seemed far too implausible to be caused by the corporate reporting system.

But the French employees relentlessly called app support whenever their clock would mysteriously change. It was always a predictable dialog.

"Ca me fait chier," Pierre would grumble. "The date! It just changed again!"

Moe T. was often the support developer on the other line.

"Did you try changing it back, Pierre?" he would ask. "You could also reboot."

Random Bug
Moe simply could not reproduce the problem. It only seemed to happen at random, and only a few times a month. That is, until two years later, when Pierre noticed a pattern.

"If we print the GL-DLG-ADM report on the fifth day of the month," he explained in an e-mail, "it will 'swap' the day and the month on our computer. So, if my computer says it's Oct. 5, then the report will change my computer date to May 10. But, this only will happen if the report is one page long."

It sounded like a superstitious diagnosis to an even stranger problem, and none of the developers believed it. No matter how many times they ran a one-page GL-DLG-ADM on their machines, their computer date remained the same.

But Pierre was insistent and demanded that Moe log in to his machine to watch the problem firsthand. Sure enough, running GL-DLG-ADM did, in fact, change Pierre's system date. The month number became the day number and the day number became the month number.

With no apparent root cause, Moe offered up a simple workaround: run single-page reports twice and, if that fails, reboot the computer. Pierre wasn't thrilled, but was content that a non-French employee had finally witnessed the problem.

Back to Basic
Moe went back and dug through the code, but couldn't find a thing. He looked at the report itself, the report generator, the report printer and the report runner ... and still, nothing. With other things taking precedence, and a workaround in place, the date issue fell onto the backburner.

That is, until a year later, when Moe just happened to flip through some VBA documentation and noticed this:

Date: returns the current system date
Note: assigning a value to Date will change the current system date to the value

He did a double take.

"Wait a sec," he said to himself. "VBA lets you set the system date by setting a value to the function?" His mind immediately jumped to the bizarre French date bug. The report used VBA Macros and must have somehow been assigning a value to Date.

After another hour of digging through sub-routine after sub-routine and script after script, he finally found the offending code buried in the page header macro:

' format the date
Date = month & "/" & day & _ 
       "/" & year

On most computers, including the developers', the code simply set the system date to the current month, day and year. On the French computers-where dates use the DD/MM/YYYY format-the code swapped the months and the days. And then, on the second page, it swapped them back. After the twelfth day of the month, when most reports were run, the line silently failed.

It took just a few minutes to fix. And after three years, the French employees could finally stop counting forms before printing, and always making sure to print an even number of pages per workstation-or failing that, rebooting after printing, which set the PC time to network time.

About the Author

Alex Papadimoulis lives in Berea, Ohio. The principal member of Inedo, LLC, he uses his 10 years of IT experience to bring custom software solutions to small- and mid-sized businesses and to help other software development organizations utilize best practices in their products. On the Internet, Alex can usually be found answering questions in various newsgroups and posting some rather interesting real-life examples of how not to program on his Web site TheDailyWTF.com. You can contact Alex directly via email at [email protected].,

comments powered by Disqus

Featured

  • See Prompts Microsoft Engineers Use for Bleeding-Edge Multimodal RAG AI Research

    Vision-centric queries show how front-line experts are prompting LLMs these days.

  • AI Explains Expressions in Update to Java on VS Code

    "The Spring Tools now show code lenses above these expressions that allow you to quickly let GitHub Copilot explain those statements for you."

  • Microsoft Eases Integration with Semantic Kernel AI SDK

    The basic idea is to provide unified API abstractions, especially for idiomatic C# code, to help platform developers and others work with any provider with standard implementations for caching, telemetry, tool calling and other common tasks.

  • Final .NET 9 Preview Ships with Go-Live License

    Visual Studio developers can now download the SDK for .NET 9 Release Candidate 2 with a go-live license, meaning devs get Microsoft support for production applications even before the framework reaches general availability next month.

Subscribe on YouTube