CodeSOD: Time Changes

This post was originally published on this site

The Daily WTF

Dates and times are way more complicated than we usually think they are, especially when we’re talking about historical dates and times. The solution, of course, is to always use someone else’s work, whether it’s a library or your language’s built-ins, never implement date handling yourself.

For a long time, though, Java’s date handling left something to be desired. Which is why Sven found this history lesson in his company’s code base:

// Those annoying Germans have stolen 1 hour and 40 minutes from us on the 16th of may 1940 // and to this day they haven’t returned them (like our bicycles). boolean is16mei1940 = year == 1940 && month == 4 && day == 16; // Before our neighbours came with the above ‘suggestion’ we did the same on the 1st of July // 1937. We adjusted the time difference with Greenwich officially from 19 minutes 28 seconds

To read the full article click on the 'post' link at the top.