• CAPTCHA Man! (unregistered)

    I'm willing to bet there use to be stuff in there and something broke one day and an intern was told to "just make it work again".

  • Brillant Bob (unregistered) in reply to CAPTCHA Man!
    Anonymous:
    I'm willing to bet there use to be stuff in there and something broke one day and an intern was told to "just make it work again".


    It is a bit scary to think that the previous code was likely worse than this.
  • Dominic Adelaar (unregistered)

    I'm not sure what the hell was happening in the first snippet, but I'm thinking in the second the author probably didn't know about Date.getFullYear (?) perhaps, and since he needed a full 4 digit date which Date.getYear doesn't provide, just wrote it in. Although in that case why he didn't write '20' + Date.getYear, I have no idea.

    That's the only reason I can come up with.

  • Chuck (unregistered)

    Ha!
    So we always want to say Last Update, but we may change it in the future...maybe
    Last Update was this morning on
    Last Update was the afternoon on
    Last Update was this evening on

    Then we need to add one to our times because heaven forbid that we compare against zero.

    And wouldn't it have been easier to just put the days of week/months in arrays like

    var now = new Date();
    var days = new Array("Sun.", "Mon.","Tues.","Wed.","Thurs.","Fri.","Sat.");
    var mths = new Array("Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sept.","Oct.","Nov.","Dec.");
    document.open();
    document.write(mths[now.getMonth()] + " " + days[now.getDay())] + " " + now.getFullYear());

    And they introduced the entire Y2K4 bug into the script...

  • Hrolf (unregistered)

    I see, the WTF is the magic numbers in the front section. It should be:

    var lunchtime = 12;
    var millertime = 17;

    That would be much clearer.

  • (cs)

    This one's stupid weak.  So many problems with it, but so obviously an unimportant task appropriately handed off to someone inexperienced, who used the "tweak it until it works" scripting technique.  Certainly not code that is critical or frequently maintained.  My guess is that it was written in about thirty minutes and never looked at again.

  • (cs)

    Hey, at least it will continue to function the same when you change web browsers, or server scripting langauges or platforms.   You can even mix and match to your hearts desire.   Trying to deicde between ASP, ASP.net, PSP, ruby on rails, uncommon web, JSP, or any have several hundred other scirpting languages on the server?   Maybe you have some Solaris servers, a Mainframe, and Windows, and are not sure which is best for running your web server on?   No problem, just write your code once on the client side (where you only have one choice), and drop it in anywhere, fully confident it will work the same no matter what you choose for your backroom.

    Brillant!

  • (cs)

    I like the first part. Especially the indentation.

  • Odoyle rules! (unregistered) in reply to hank miller

    Forgive me for my simplistic view but isn't the biggest WTF that fact that the last update doesn't reflect anything other than the user's clock?

  • (cs)

    So, wait, "monthName" contains the month number? And then "Month" (never declared) contains the month name?

    And not only does "dayName" get a number, and the undeclared "Day" get the name, but neither variable is ever used for anything.

    What crap.

     

  • (cs) in reply to Odoyle rules!
    Anonymous:

    Forgive me for my simplistic view but isn't the biggest WTF that fact that the last update doesn't reflect anything other than the user's clock?



    Nope - that's a reflection of the corporation's overall relationship with the customer. The company last updated whenever the customer says they did.
  • (cs) in reply to Odoyle rules!
    Anonymous:
    Forgive me for my simplistic view but isn't the biggest WTF that fact that the last update doesn't reflect anything other than the user's clock?


    Well...

    Since the page is generated dynamically, at least for the last update<EG>, that is accurate in a way, in a WTF way.

    Sincerely,

    Gene Wirchenko

  • (cs)

    Aw, come on, it was right for a whole year, that's not too bad. Even a Mercedes needs to go back for maintenance that often.......

     

    Man, this one made me laugh out loud - Best punchline code I've seen in ages!

  • (cs)

    I don't know if I should be impressed or nauseated that someone went through all this trouble to learn how to print a date, and then assumed this would only be used until December 31, 2004. Get the day, get the month... why not just get the year too!?

    Maybe there's an action item on someone's list that states every January 1st someone needs to edit this document to update the year. Or better yet, someone calls this "developer" every year to say "Oh no! The website is showing LAST YEAR'S DATE!!! Can you help us!?"  "Yep, I sure can. It will cost $2,000 to fix this bug. See you next year."

  • (cs) in reply to Gene Wirchenko
    Gene Wirchenko:
    Anonymous:
    Forgive me for my simplistic view but isn't the biggest WTF that fact that the last update doesn't reflect anything other than the user's clock?


    Well...

    Since the page is generated dynamically, at least for the last update<eg>, that is accurate in a way, in a WTF way.

    Sincerely,

    Gene Wirchenko



    I respectfully disagree with that summation.

    Sincerely,

    Richard Nixon
    </eg>
  • (cs) in reply to Manni
  • (cs) in reply to Manni
    Manni:

    I don't know if I should be impressed or nauseated that someone went through all this trouble to learn how to print a date, and then assumed this would only be used until December 31, 2004. Get the day, get the month... why not just get the year too!?

    Maybe there's an action item on someone's list that states every January 1st someone needs to edit this document to update the year. Or better yet, someone calls this "developer" every year to say "Oh no! The website is showing LAST YEAR'S DATE!!! Can you help us!?"  "Yep, I sure can. It will cost $2,000 to fix this bug. See you next year."

    sorry, replied instead of quoted - http://despair.com/consulting.html

  • Rainman (unregistered) in reply to Odoyle rules!

    Well, technically, it was the user's clock in 2004.

  • (cs) in reply to Dominic Adelaar

    Dominic Adelaar:
    I'm not sure what the hell was happening in the first snippet, but I'm thinking in the second the author probably didn't know about Date.getFullYear (?) perhaps, and since he needed a full 4 digit date which Date.getYear doesn't provide, just wrote it in. Although in that case why he didn't write '20' + Date.getYear, I have no idea.

    More likely, he started writing:

    <FONT face="Courier New">var yearNumber = now.getYear();
    if(yearNumber==0) Year= "2000";
    if(yearNumber==1) Year= "2001";
    if(yearNumber==2) Year= "2002";</FONT>

    And then he thought, "God, I don't want to do this 100 times. I'll just put in 2004. I'll be working somewhere else a year from now."

    Of course if he had known about getFullYear, he would've started with:

    <FONT face="Courier New">var yearNumber = now.getFullYear();
    if(yearNumber==0) Year= "0";
    if(yearNumber==1) Year= "1";
    </FONT>...

    --RA

     

  • (cs) in reply to Rank Amateur

    Forgive me for my simplistic view but isn't the biggest WTF that fact that the last update doesn't reflect anything other than the user's clock?

    ++

  • (cs)

    Well, at least the algorithm is O(1).

  • A! (unregistered) in reply to Manni
    Manni:

    I don't know if I should be impressed or nauseated that someone went through all this trouble to learn how to print a date, and then assumed this would only be used until December 31, 2004. Get the day, get the month... why not just get the year too!?

    Maybe they didn't anticipate to stay in business that long.

  • (cs) in reply to Rank Amateur
    Rank Amateur:

    Dominic Adelaar:
    I'm not sure what the hell was happening in the first snippet, but I'm thinking in the second the author probably didn't know about Date.getFullYear (?) perhaps, and since he needed a full 4 digit date which Date.getYear doesn't provide, just wrote it in. Although in that case why he didn't write '20' + Date.getYear, I have no idea.

    More likely, he started writing:

    <FONT face="Courier New">var yearNumber = now.getYear();
    if(yearNumber==0) Year= "2000";
    if(yearNumber==1) Year= "2001";
    if(yearNumber==2) Year= "2002";</FONT>

    And then he thought, "God, I don't want to do this 100 times. I'll just put in 2004. I'll be working somewhere else a year from now."

    Of course if he had known about getFullYear, he would've started with:

    <FONT face="Courier New">var yearNumber = now.getFullYear();
    if(yearNumber==0) Year= "0";
    if(yearNumber==1) Year= "1";
    </FONT>...

    --RA

     

    he he! Exactly !

    And i do feel that the WTF is a combination of bad code and the complete misrepresentation of how often the site's content is updated.

     

  • anon (unregistered) in reply to JohnO
    JohnO:
    Well, at least the algorithm is O(1).


    Only because it employs "caching".
  • A! (unregistered)

    As far hardcoding year.... maybe it is an optimiztion technique [:P]

  • meh (unregistered) in reply to Dominic Adelaar

    '20' + Date.getYear will either display '2004' or '20104' depending on the browser.

  • meh (unregistered) in reply to meh

    Erm, I was in replying to Dominic Adelaar's post.

  • (cs) in reply to hank miller
    hank miller:
    Hey, at least it will continue to function the same when you change web browsers, or server scripting langauges or platforms.   You can even mix and match to your hearts desire.   Trying to deicde between ASP, ASP.net, PSP, ruby on rails, uncommon web, JSP, or any have several hundred other scirpting languages on the server?   Maybe you have some Solaris servers, a Mainframe, and Windows, and are not sure which is best for running your web server on?   No problem, just write your code once on the client side (where you only have one choice), and drop it in anywhere, fully confident it will work the same no matter what you choose for your backroom.

    Brillant!


    How about using XHTML?
  • (cs)

    Are we sure this isn't on a page that hasn't changed since 2004 ?

    Whoever coded this obviously knew there would be no more updates after 2004, so I think we should give them credit for not trying to fool us into thinking that they have been updating this page.

    [<:o)]

     

  • Brian (unregistered)

    Makes me wonder if this is the same quality code used in this "Software Vendor's" software!

  • Jim Hauser (unregistered)

    One of my students refered me to this site.[*]  It reminds me of a 1983 saying: Opus says "Don't look for logic." After 20 yrs in industry as a SE I thought I had seen it all...Hauser, PhD.  see www.nku.edu/~hauserj for a good review.  By the way .... building stuff is more fun; less rewarding.

     

  • Tony Morris (unregistered) in reply to kipthegreat
    kipthegreat:
    This one's stupid weak.  So many problems with it, but so obviously an unimportant task appropriately handed off to someone inexperienced, who used the "tweak it until it works" scripting technique.  Certainly not code that is critical or frequently maintained.  My guess is that it was written in about thirty minutes and never looked at again.


    You seem to imply that rotten code is not critical or frequently "maintained" (loosely speaking). Or that the worst code is written by (claimed) "inexperienced" people. I sometimes wonder if there really is an ideal world out there, but in my world, none of this holds true.
  • Jboy (unregistered)

    Looks like they fixed it..

    http://www.netcoast.nl/

     <script
    language
    ="JavaScript">

    var now = new Date();

    var dayName = now.getDay() +1;
    var dayNumber = now.getDate();
    var monthName = now.getMonth() + 1;



    if(dayName==1) Day = "Sunday";
    if(dayName==2) Day = "Monday";
    if(dayName==3) Day = "Tuesday";
    if(dayName==4) Day = "Wednesday";
    if(dayName==5) Day = "Thursday";
    if(dayName==6) Day = "Friday";
    if(dayName==7) Day = "Saturday";

    if(monthName==1) Month="Jan.";
    if(monthName==2) Month="Feb.";
    if(monthName==3) Month="Mar.";
    if(monthName==4) Month="Apr.";
    if(monthName==5) Month="May";
    if(monthName==6) Month="Jun.";
    if(monthName==7) Month="Jul.";
    if(monthName==8) Month="Aug.";
    if(monthName==9) Month="Sept.";
    if(monthName==10) Month="Oct.";
    if(monthName==11) Month="Nov.";
    if(monthName==12) Month="Dec.";

    document.open();
    document.write( Day + ", " + dayNumber + " " + Month);
    </script>
    2005</font>


  • (cs) in reply to Jboy

    LOL...

    Yes, now when 2006 comes along even those with Javascript disabled will be able to see the incorrect year.

  • (cs) in reply to Dominic Adelaar

    Anonymous:
    I'm not sure what the hell was happening in the first snippet, but I'm thinking in the second the author probably didn't know about Date.getFullYear (?) perhaps, and since he needed a full 4 digit date which Date.getYear doesn't provide, just wrote it in. Although in that case why he didn't write '20' + Date.getYear, I have no idea.

    That's the only reason I can come up with.

    He's writing "Last updated:" As long as the time returned is between 00 and 23 hours...

  • (cs) in reply to Jboy
    Anonymous:
    Looks like they fixed it..

    http://www.netcoast.nl/

     <script
    language
    ="JavaScript">

    var now = new Date();

    var dayName = now.getDay() +1;
    var dayNumber = now.getDate();
    var monthName = now.getMonth() + 1;



    if(dayName==1) Day = "Sunday";
    if(dayName==2) Day = "Monday";
    if(dayName==3) Day = "Tuesday";
    if(dayName==4) Day = "Wednesday";
    if(dayName==5) Day = "Thursday";
    if(dayName==6) Day = "Friday";
    if(dayName==7) Day = "Saturday";

    if(monthName==1) Month="Jan.";
    if(monthName==2) Month="Feb.";
    if(monthName==3) Month="Mar.";
    if(monthName==4) Month="Apr.";
    if(monthName==5) Month="May";
    if(monthName==6) Month="Jun.";
    if(monthName==7) Month="Jul.";
    if(monthName==8) Month="Aug.";
    if(monthName==9) Month="Sept.";
    if(monthName==10) Month="Oct.";
    if(monthName==11) Month="Nov.";
    if(monthName==12) Month="Dec.";

    document.open();
    document.write( Day + ", " + dayNumber + " " + Month);
    <!--<span class="end-tag"-->script>
    2005<!--<span class="end-tag"-->font>




    OMFG it's real.

  • Paul O (unregistered) in reply to emurphy

    Shouldn't someone have commented by now that this looks like a great opportunity to use regex? :)

  • DeusEx (unregistered)

    This kind of crap really bugs me:

    Englishly Challenged:
    if(dayName==4) Day = "Wed.";
    if(dayName==5) Day = "Thur.";
    if(dayName==6) Day = "Fri.";

    if(monthName==6) Month="June";
    if(monthName==7) Month="July";
    if(monthName==8) Month="Aug.";
    if(monthName==9) Month="Sept.";


    Either abbreviate consistently or don't abbreviate at all. 3 letters and a period is all you need. Did anyone ever think "Thu." was any other day but Thursday? Or that "Sep." was a month besides September?

    And yes, you should abbreviate "June" and "July" too.
  • Brandon Driesen (unregistered) in reply to Gene Wirchenko

    When a page is declared to be updated, it means content being updated. The javascript on the other hand, does nothing but just provide the current date (with the exception of the year) and therefore is DISINGENIOUS and DECEPTIVE.

    Page being dynamically generated is irrelevant. If the content is the same, the date cannot be today. The WTF here is clearly that the date is not determined server-side whereby the actual date of the last update could be retrieved from a data source, or hard-coded client-side. Either solution is more honest and true than dynamic client-side scripts that give the end-user the impression that the page has just been updated.

    More importantly, it would be obvious to that end-user were his computer time in the future.


  • jawohl (unregistered) in reply to meh
    Anonymous:
    '20' + Date.getYear will either display '2004' or '20104' depending on the browser.
    And thats why there's Date.getFullYear() which returns 2004.
  • badong (unregistered) in reply to Brandon Driesen

    They seem to have removed the "Last Updated" part. It's now only stating the date, which imho is an important piece of information that can come in quite handy.

  • (cs) in reply to badong

    Anonymous:
    They seem to have removed the "Last Updated" part. It's now only stating the date, which imho is an important piece of information that can come in quite handy.

    Exactly. Taking a look into computer's own clock is so awkward. That's why I don't do that but surf to their site to see the time. It's also more reliable as you never know what time the server might have.

  • (cs)

    Ironically, we can't tell when this code was written, because the "last updated" information is buggy.

  • csrster (unregistered)

    I love it. A DailyWTF with an actual punchline.

  • Nand (unregistered) in reply to Jboy
    if(dayName==1) Day = "Sunday";
    if(dayName==2) Day = "Monday";
    if(dayName==3) Day = "Tuesday";
    if(dayName==4) Day = "Wednesday";
    if(dayName==5) Day = "Thursday";
    if(dayName==6) Day = "Friday";
    if(dayName==7) Day = "Saturday";

    if(monthName==1) Month="Jan.";
    if(monthName==2) Month="Feb.";
    if(monthName==3) Month="Mar.";
    if(monthName==4) Month="Apr.";
    if(monthName==5) Month="May";
    if(monthName==6) Month="Jun.";
    if(monthName==7) Month="Jul.";
    if(monthName==8) Month="Aug.";
    if(monthName==9) Month="Sept.";
    if(monthName==10) Month="Oct.";
    if(monthName==11) Month="Nov.";
    if(monthName==12) Month="Dec.";


    <sarcasm>The horrible if/switchery is needed because the author must make sure dates are always displayed in english, and not possibly some locale that uses different month names!</sarcasm>
  • Oli (unregistered)

    That's just downright dirty. I can forgive the bad code, but the real WTF HAS to be the fact that they're lying to their customers about how often the site is updated. They could have at least been sneaky about it by writing it via some server-side code...

    I can just image some fatcat in the company saying "I want it to look like we update our site every day!" and then forcing the hapless intern web developer who's on £4/hr to write the arocity.

  • Nitboy (unregistered) in reply to Manni

    Manni:
    Maybe there's an action item on someone's list that states every January 1st someone needs to edit this document to update the year. Or better yet, someone calls this "developer" every year to say "Oh no! The website is showing LAST YEAR'S DATE!!! Can you help us!?"  "Yep, I sure can. It will cost $2,000 to fix this bug. See you next year."

    2000$

    My firm would use perhaps 200 man hours fixing this...

    So 2000$ would be quite cheap..

  • (cs) in reply to Paul O
    Meh:
    '20' + Date.getYear will either display '2004' or '20104' depending on the browser.

    Paul O:
    Shouldn't someone have commented by now that this looks like a great opportunity to use regex? :)


    I'll bite.  They could use something like this "s/^(\d{2})\d{0,1}(\d{2})$/\1\2/" to fix it.  I, for one, vote for doing a mod 100 on the result of getYear before prepending the 20.  Let the Y3K people fix it.

    Note to Nitpickers:  I stay away from front ends of all kinds, and with good reason.  I'm guessing that most browsers don't have a decent regex engine available for scripting.  While I'd be surprised if there was no mod expression, I'm not sure what format it would take.
  • Andr&#233;s Villanueva (unregistered)

    It would be funny to enter the site on a february 29th, but we won't have one of those till 2008, and they'll probably fix that by then ;)

  • (cs) in reply to Jim Hauser

    Anonymous:
    One of my students refered me to this site.[*]  It reminds me of a 1983 saying: Opus says "Don't look for logic." After 20 yrs in industry as a SE I thought I had seen it all...Hauser, PhD.  see www.nku.edu/~hauserj for a good review.  By the way .... building stuff is more fun; less rewarding.

    <FONT face="Courier New" size=2>what...is going on in that site?</FONT>

Leave a comment on “Automatic Updates”

Log In or post as a guest

Replying to comment #:

« Return to Article