- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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".
Admin
It is a bit scary to think that the previous code was likely worse than this.
Admin
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.
Admin
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...
Admin
I see, the WTF is the magic numbers in the front section. It should be:
That would be much clearer.
Admin
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.
Admin
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!
Admin
I like the first part. Especially the indentation.
Admin
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?
Admin
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.
Admin
Nope - that's a reflection of the corporation's overall relationship with the customer. The company last updated whenever the customer says they did.
Admin
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
Admin
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!
Admin
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."
Admin
I respectfully disagree with that summation.
Sincerely,
Richard Nixon
</eg>
Admin
http://despair.com/consulting.html
Admin
sorry, replied instead of quoted - http://despair.com/consulting.html
Admin
Well, technically, it was the user's clock in 2004.
Admin
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
Admin
++
Admin
Well, at least the algorithm is O(1).
Admin
Maybe they didn't anticipate to stay in business that long.
Admin
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.
Admin
Only because it employs "caching".
Admin
As far hardcoding year.... maybe it is an optimiztion technique [:P]
Admin
'20' + Date.getYear will either display '2004' or '20104' depending on the browser.
Admin
Erm, I was in replying to Dominic Adelaar's post.
Admin
How about using XHTML?
Admin
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)]
Admin
Makes me wonder if this is the same quality code used in this "Software Vendor's" software!
Admin
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.
Admin
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.
Admin
Looks like they fixed it..
http://www.netcoast.nl/
Admin
LOL...
Yes, now when 2006 comes along even those with Javascript disabled will be able to see the incorrect year.
Admin
He's writing "Last updated:" As long as the time returned is between 00 and 23 hours...
Admin
OMFG it's real.
Admin
Shouldn't someone have commented by now that this looks like a great opportunity to use regex? :)
Admin
This kind of crap really bugs me:
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.
Admin
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.
Admin
Admin
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.
Admin
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.
Admin
Ironically, we can't tell when this code was written, because the "last updated" information is buggy.
Admin
I love it. A DailyWTF with an actual punchline.
Admin
<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>
Admin
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.
Admin
2000$
My firm would use perhaps 200 man hours fixing this...
So 2000$ would be quite cheap..
Admin
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.
Admin
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 ;)
Admin
<FONT face="Courier New" size=2>what...is going on in that site?</FONT>