Microsoft WTF, old, but just come to my attention.



  • I'm coding a converstion between some Julian day numbers and Excel serial date number. Easy enough you say, Excel serial date numbers start in 1/1/1900, just minus the julian day number for that date from your current julian day number. But no, it's not quite that simple, you see, microsoft thought it'd be fun to have 1/1/1900 be the FIRST day, so 1/1/1900 is day 1 not day 0. Ok, so we subtract 31/12/1899 from our current julian day number and this works, so long as our date is before 1/3/1900. For some reason unknown to the rest of the world, Microsoft thought it'd be fun to make 1900 a leap year, which is it not, so 1900 has the day 29/2/1900 meaning that any day after that will be off by one.
    So, not only do we subtract 31/12/1899 from our julian date, but if it's > 60, we have to add one to it or it won't be a proper excel date :(

    http://www.calendarhome.com/converter/excel.html



  • Isn't this pretty obvious? A simple % 4 test is a whole lot faster than checking % 100 and 400 as well (keep in mind that 4 is a nice binary value).
    According to Joel Spolsky this behaviour was inherited from Lotus 123 ( http://www.joelonsoftware.com/items/2006/06/16.html ).



  • This is one of those little obscure pieces of information every programmer should know, and as doynax said, Joel's books and website are a good place to find them out.

     On the original IBM PC, there were several BIOS calls that did not save the BX register.  Programs that ran fine on clones wouldn't work on a genuine IBM PC.  (OK, you can forget that one now.  Those days are long gone.)

     

     



  • Why is this surprising to anyone?

    I haven't yet decided whether MS does these things on purpose or through sheer stupidity. 

    J++/Java interoperability errors, DOS 1MB memory addressing kludge, and the Windows API in its various evil incarnations are high points that continue to baffle me.  Don't get me started on IE's track record in the standards arena...
     

     



  • @Parvo93 said:

    Why is this surprising to anyone?

    I haven't yet decided whether MS does these things on purpose or through sheer stupidity. 

    I'd say it was a valid design decision at the time, saving memory and clock cycles was deemed preferable to allowing dates before 1901 to work fully. And Microsoft, in turn, preferred implementing a kludge to deal with those early dates to skipping Lotus 123 compatibility.
    Neither decision is a WTF by any standards.

    @Parvo93 said:

    J++/Java interoperability errors, DOS 1MB memory addressing kludge, and the Windows API in its various evil incarnations are high points that continue to baffle me.  Don't get me started on IE's track record in the standards arena...

    I'd say both IE's incompatibilities and Java's extensions makes perfect business sense. They're trying to maintain a monopoly after all, and you don't do that by making it easy for people to switch away from your products.

    As for the Windows API it definitely suffers from backwards
    compatibility, incremental development since the beginning of time, and
    repeated attempts to provide an API for everything imaginable. Nearly
    all of it was done for a valid reasons through informed decisions which
    made business sence at the time. Microsoft may be "evil capitalists"
    but they're certainly not stupid.

    <font size="-1"></font>

    <font size="-1"></font>

    And I truly cannot see how Microsoft could be blamed for the 1 MB addressing limit in DOS. The 8086 processor has a 1 MB address space, and the PC's memory map is designed in such a way that 640 KB is the largest possible contiguous block of RAM. Those were Intel and IBM's decisions respectively.

    <font size="-1">To quote Raymond Chen: "When you don't have a time machine, you have to live with your mistakes."</font>


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.