Still worried about y2k 7 years later.



  • This javascript was found on an internal website and was used to display a simple welcome message with the date.

     <FONT size=2>if (today.getYear() == 99) {

    theYear = "1999";

    }

    else {

    theYear = 2006;

    }

     

    Of course this was fixed with

    <FONT size=2>

    theYear = today.getYear();

    </FONT></FONT>


  • @mattwho said:

    This javascript was found on an internal website and was used to display a simple welcome message with the date.

     <FONT size=2>if (today.getYear() == 99) {

    theYear = "1999";

    }

    else {

    theYear = 2006;

    }

     

    Of course this was fixed with

    <FONT size=2>

    theYear = today.getYear();

    </FONT></FONT>

    Probably better would've been:

    var theYear = today.getYear() + ((today.getYear() < 1000 /* ? 1 : 0 */) * 1900);
    

    ... Assuming javascript is sane and casts boolean true/false to integer 1/0 nicely (as opposed to VB's -1/0). And if javascript instead decides to be a bitch and do something else entirely, just uncomment the ternary. Of course it fails if someone goes back in time to see the roman empire and browse your not-yet-existing website from back then.

    (edit: damn HTML entities, also it does work, becuase I tested it in both opera and firefox, which imho are the only browsers that matter (IE can get stuffed))



  • @mattwho said:

    This javascript was found on an internal website and was used to display a simple welcome message with the date.

     <font size="2">if (today.getYear() == 99) {</font>

    <font size="2">theYear = "1999";</font>

    <font size="2">}</font>

    <font size="2">else {</font>

    <font size="2">theYear = 2006;</font>

    <font size="2">}</font>

    <font size="2"> </font>

       Hey, what happened to all the years between 2000 and 2005?  Are you suggesting that once a year every year on New Year's Day, somebody had to manually edit that else clause to advance the year, all the while carefully preserving the if clause in case 1999 ever came back?  I guess the real WTF is that it should say...

     

     <font size="2">if (today.getYear() == 99) {</font>

    <font size="2">theYear = "2099";</font>

    <font size="2">}</font>

    <font size="2">else {</font>

    <font size="2">theYear = 2006;</font>

    <font size="2">}</font>

     

    ... by now!

     



  • @DaveK said:

    Hey, what happened to all the years between 2000 and 2005? Are you suggesting that once a year every year on New Year's Day, somebody had to
    manually edit that else clause to advance the year, all the while carefully preserving the if clause in case 1999 ever came back?

    Hahahahaha .... Oh man. And yes, sadly, I think this is just what did happen. "Ooo looky I wonder what this does? Hm ... I don't understand, I'd better leave it alone."

    I always prefer to rip out anything I don't understand and start over, but I get stumped too. One site I'm rebuilding little piece at a time has a CSS style set on the "span" tag. Span. Every span on the whole site gets a yellow background IIRC, so I can't use one without getting inadvertent colourisation. Now, I don't see too many span tags, so I'd have to download the whole site and go through it with a search to find who's abusing span like that.

    But this year code was written by Captain Obvious and whoever preserved that year after year is either in desperate need of a smack upside the head, or his other car is a blue police box.



  • @mattwho said:

    Of course this was fixed with

    theYear = today.getYear();
    ECMA-262 specifies that getYear() should return the number of years since 1900. Although Internet Explorer doesn't comply, Opera and Firefox do, so the code is still broken. The code aquanight posted works around this problem.


  • @HeroreV said:

    @mattwho said:
    Of course this was fixed with

    theYear = today.getYear();
    ECMA-262 specifies that getYear() should return the number of years since 1900. Although Internet Explorer doesn't comply, Opera and Firefox do, so the code is still broken. The code aquanight posted works around this problem.

    The code aquanight posted solves the wrong problem. The real WTF is that getYear() is deprecated (and has been since about 1997), and getFullYear() should be used instead.


  • @Daniel Beardsmore said:

    @DaveK said:

    Hey, what happened to all the years between 2000 and 2005? Are you suggesting that once a year every year on New Year's Day, somebody had to
    manually edit that else clause to advance the year, all the while carefully preserving the if clause in case 1999 ever came back?

    Hahahahaha .... Oh man. And yes, sadly, I think this is just what did happen. "Ooo looky I wonder what this does? Hm ... I don't understand, I'd better leave it alone."

    OMFG this is so good. This thread just made my day. 



  • @aquanight said:

    (edit: damn HTML entities, also it does work, becuase I tested it in both opera and firefox, which imho are the only browsers that matter (IE can get stuffed))

     
    The real WTF is that people think IE compatibility doesn't matter when that's what 80% of the public is using.

    (Yay!  After almost a year of commenting, I finally used the phrase "the real WTF"!)



  • @Jojosh_the_Pi said:

    @aquanight said:

    (edit: damn HTML entities, also it does work, becuase I tested it in both opera and firefox, which imho are the only browsers that matter (IE can get stuffed))

    The real WTF is that people think IE compatibility doesn't matter when that's what 80% of the public is using.


    It all depends on your audience.  For my website, IE usage is almost down to the point where I don't need to worry about being compatible with it anymore: last month, people using IE only made up 31% of the total traffic.



  • @Jojosh_the_Pi said:

    @aquanight said:

    (edit: damn HTML entities, also it does work, becuase I tested it in both opera and firefox, which imho are the only browsers that matter (IE can get stuffed))

     
    The real WTF is that people think IE compatibility doesn't matter when that's what 80% of the public is using.

    (Yay!  After almost a year of commenting, I finally used the phrase "the real WTF"!)

    The real WTF is that IE can't follow the standards that 80% (at least) of the browsers follow. I can't say I've ever tried it myself, but I've heard only horror stories about keeping sites compatible with both IE and actual compliant browsers (firefox, opera, etc) in a reasonably sane manner (ie: something other than javascript browser detection (== unreliable - people can turn off JS these days and have good reasons to usually, and no site should ever be rendered utterly useless just because someone doesn't want to turn on JS (yes I know ~all browsers have popup blockers. popups aren't the only thing that are annoying (gee is this looing like lisp yet?))) followed by appropriate assignment of external CSS file).

    I, of course, invite you to prove me wrong that IE does follow the standards, but I find that highly unlikely, considering M$ pretty much likes to do anything but follow the standard (see, for example, their pre-.NET C++ compiler - they only started being C89 compliant in .NET (probably even as late as .NET 2003) or something).



  • The idea that IE follows standards ... heh. I can only assume that you're a visitor from Planet Optimism.



  • @Carnildo said:


    It all depends on your audience.  For my website, IE usage is almost down to the point where I don't need to worry about being compatible with it anymore: last month, people using IE only made up 31% of the total traffic.


    You're willing to ignore almost 1/3 of your traffic?



  • @SuperousOxide said:

    @Carnildo said:

    It all depends on your audience.  For my website, IE usage is almost down to the point where I don't need to worry about being compatible with it anymore: last month, people using IE only made up 31% of the total traffic.


    You're willing to ignore almost 1/3 of your traffic?

    No, but if the current trend continues, IE will be below 10% by summer, at which point I will start ignoring it.



  • IE7 seems much better, at least when it comes to CSS. The download page for one of my programs was pretty broken with IE<=6 (something to do with box model IIRC; I never cared about it - the page looked fine in other browsers, and it was still usable in IE, although the download links were somewhat cut-off - it never prevented the program from being in top-10 downloads on that particular site), but works fine with IE7. I also noticed that pure CSS drop-down menus work almost properly now (the roll-downs open, although not in quite the correct place).



  • @Carnildo said:

    For my website, IE usage is almost down to the point where I don't need to worry about being compatible with it anymore: last month, people using IE only made up 31% of the total traffic.

    The real question is, are the IE users being replaced by Firefox and Opera users, or just... not coming back?

    I had a similar discussion with someone about meth imports. He said before the pseudoephedrine ban, only 30% of meth in our area was imported from Mexico by organised crime; now, 90% of it is. So I gave him an example: 600 pounds of meth is distributed. 180 pounds came from Mexico, which is 30%, and the other 70% (420 pounds) came from domestic labs. If we shut down almost all of the domestic labs, removing 400 pounds of domestic meth from the streets, we have 200 pounds of meth on the street... 20 pounds (10%) domestic, 180 pounds (90%) imported from Mexico. The percentages look like things are getting worse, but the real imports in pounds haven't changed at all, and it could probably be argued that taking 400 pounds of meth off the streets is an advance.

     



  • @Carnildo said:


    It all depends on your audience. For my website, IE usage is almost down to the point where I don't need to worry about being compatible with it anymore: last month, people using IE only made up 31% of the total traffic.

    Only 31% of your audience?   That's almost one out of every
    three people!  That's a lot of people you're not trying to accommodate,
    especially if you're a business.

    The fact the IE7 isn't standards
    compatible is irrelevant.  Unless you're actively trying to discourage
    IE users, it's worth the effort to try to get a working page for all
    major browsers.  Most people don't know and don't care about which browser is better
    (well, your audience may be different, but apparently, 1/3 of your
    audience is not up to snuff). Vital, vital if your website is capturing
    business.

    Maybe the reason the percentage of IE users is going down is because they can't use the page, and they don't come back.

    Heck, I only have a personal site with a lower
    percentage of IE users, but it's inevitable that IEers will show
    up...the very least I can do is not drive away potential users from
    using my site.

     



  • Since it's used on an internal website and the only approved browser is IE, IE is the only browser that matters.



  • @Jojosh_the_Pi said:

    @Carnildo said:
    It all depends on your audience. For my website, IE usage is almost down to the point where I don't need to worry about being compatible with it anymore: last month, people using IE only made up 31% of the total traffic.

    Only 31% of your audience?   That's almost one out of every
    three people!  That's a lot of people you're not trying to accommodate,
    especially if you're a business.

    Note my use of the word "almost".  Right now, the site does accomodate IE.  If the current trends continue, though, I'll stop testing for IE compatibility sometime this summer.

    Maybe the reason the percentage of IE users is going down is because they can't use the page, and they don't come back.

    The majority of the change is from new traffic, which is almost invariably Firefox (the main source of new traffic for my site is a forum with a [i]very[/i] vocal Firefox advocate).  The rest is from people changing browsers, split roughly evenly between IE -> Firefox, IE -> Opera, and IE -> Safari.



  • @Carnildo said:

    The majority of the change is from new traffic, which is almost invariably Firefox (the main source of new traffic for my site is a forum with a [i]very[/i] vocal Firefox advocate). The rest is from people changing browsers, split roughly evenly between IE -> Firefox, IE -> Opera, and IE -> Safari.

    You know your site best.  For some reason, I got the impression your site didn't handle IE users, which is what I get for reading the messages too quickly 'cause I'm at work.

    I don't know what business you're in.  In the airlines, numbers as small as 2% make a huge difference--even for a smaller, regional airline.  Seeing 31% reflexively triggered "crud, that's huge!" neurons in my brain.

     



  • The problem is there are people who don't know what a browser is yet they use one every day...



  • @nickfitz said:

    @HeroreV said:
    @mattwho said:
    Of course this was fixed with

    theYear = today.getYear();
    ECMA-262 specifies that getYear() should return the number of years since 1900. Although Internet Explorer doesn't comply, Opera and Firefox do, so the code is still broken. The code aquanight posted works around this problem.

    The code aquanight posted solves the wrong problem. The real WTF is that getYear() is deprecated (and has been since about 1997), and getFullYear() should be used instead.

    Correct.  

    Forget getYear. only use getFullYear. I'm not sure in what situation a two-digit year is useful -- especially since we still live near the millennium turn.

    Assuming javascript is sane and casts boolean true/false to integer 1/0 nicely (as opposed to VB's -1/0)

    Correct.

    Essay Answers!

    The sanity of implicitly casting a real, existing number to boolean is debatable. I'd prefer that if (0) { print "pass"; } would pass, because 0 exists, but an explicit (bool) 0; would create false. Because the thing is, sometimes 0 is a valid, informative value for a variable, and you only want the null value to fail the if.

    But perhaps that's largely academic, because a var that should contain a real number (such as a loopCount or priceMultiplier) should also, by proper program design, never contain null, and never exist alone in a cold if check.


Log in to reply
 

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