• (cs)

    The only way that I can currently think of to make that worse is to expect the user to enter the month in Morse code!

  • (cs)

    I know nothing of web development, but wouldn't it be reasonable to assume that there is some sort of calendar widget available that one might use instead of writing all that?

  • Nagesh (unregistered)

    I see no problem with this code. It is a work of art!

  • jonny_q (unregistered) in reply to snoofle
    snoofle:
    I know *nothing* of web development, but wouldn't it be reasonable to assume that there is some sort of calendar widget available that one might use instead of writing all that?

    HTML5 allows for <input type=date> and as browsers gain support for it, it will be that simple to display a date widget.

    However, even today, not all browsers support it. Like the article said, there are a number of third-party scripts out there that do the job quite well. A very method is to include the jQuery UI lib on your page:

    <label>Date <input class=date name=birthdate></label>
    ... 
    <script>$(function() {
     $('input.date').datepicker();
     // wipe hands on pants
    });</script>
    

    So, yes.

    I dumbed down the code there a bit, and there's probably a more thorough answer, but that's the quick answer to your question.

  • DWalekr59 (unregistered)

    Instead of JUST laughing at the programmer here, someone should replace that code with what ought to be there and then SHOW IT TO the programmer. Ask them what they think of the replacement.

    Make a comment to them like "you know, there are some situations where, when you see them, you ought to think "I'm sure this has been solved before -- let's look around for the best and simplest way to implement this".".

  • Kasper (unregistered)

    There is not much reason to be using javascript in the first place. That page could have worked just as fine without any javascript. The only thing that javascript could really do for such a page is to present an error message to the user slightly faster, if the input is inconsistent (like specifying the 30th of February or such).

    You are going to need validation on the server side anyway. As a user I'd much rather see a solution that only validates on the server side than one, that does a poor job of validating on the client side.

  • (cs) in reply to GettinSadda

    Obviously you lack creativity. The worse version would involve inputting the date in Julian and writing a routine to convert it to Gregorian.

  • Chronomium (unregistered)

    Why is the year box about 40% wider than the other two?

    Why is "check" abbreviated in the comments to "ck"?

    Why Are the Alerts in Title Case!?

    Why is the order month/day/year?

    So many subtle things here.

  • Patrick Bell (unregistered)

    Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

    Dear Daily WTF,

    I came for the lulz, and left because of the sickening elitism among your submitters and commentors whose lives are now so devoid of meaning that the only pleasure they get is derived from heckling the less gifted.

    Enjoy your passive aggressive snickering and your tiny cubicles while you hide from doing real work.

    plonk

    Sincerely, Patrick

  • Anon (unregistered) in reply to Patrick Bell
    Patrick Bell:
    Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

    Dear Daily WTF,

    I came for the lulz, and left because of the sickening elitism among your submitters and commentors whose lives are now so devoid of meaning that the only pleasure they get is derived from heckling the less gifted.

    Enjoy your passive aggressive snickering and your tiny cubicles while you hide from doing real work.

    plonk

    Sincerely, Patrick

    Looks like the author of today's submission has been unearthed.

  • An on (unregistered)

    // final Date string to be passed to SAP is stored here

                                        ^^^^^
    

    That's your first clue as to "why" right there.

    Once you've spent some time with SAP, anything else looks good, especially on the UI front...

  • Tim (unregistered) in reply to Kasper
    Kasper:
    There is not much reason to be using javascript in the first place. That page could have worked just as fine without any javascript. The only thing that javascript could really do for such a page is to present an error message to the user slightly faster, if the input is inconsistent (like specifying the 30th of February or such).

    You are going to need validation on the server side anyway. As a user I'd much rather see a solution that only validates on the server side than one, that does a poor job of validating on the client side.

    Kasper is correct. You must validate all data on the server, because you cannot count on being in control of the client. Once you understand that, client-scripted validation is merely sugar to help the babies who don't know how to enter dates yet.

  • mrfr0g (unregistered) in reply to Patrick Bell
    Patrick Bell:
    Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

    Dear Daily WTF,

    I came for the lulz, and left because of the sickening elitism among your submitters and commentors whose lives are now so devoid of meaning that the only pleasure they get is derived from heckling the less gifted.

    Enjoy your passive aggressive snickering and your tiny cubicles while you hide from doing real work.

    plonk

    Sincerely, Patrick

    Hey congratulations! You just got the point of this website, to make fun of poorly written code. Today it is a javascript WTF, tomorrow it might be c/c++, Java, classic ASP, or really anything else "code" related.

    I am a Web Developer, have been for a number of years and I can say with certainty that the code posted today is terrible, and deserves to be made fun of.

    CATPCHA: letatio, some kind of levitating potato or Harry Potter spell

  • (cs)

    This is why college education is broken. They teach you so many things, except to look at the API. Go to any college class which is doing any development and show them the API to their current language... the looks of awe are simply amazing and the sheep stand there wondering of a whole new world of opportunities. So please people, stop reinventing new ways of fucking up date implementations. How many articles have appeared here where the subject is implementing his/her new Gregorian calendar? Oh! And TRWTF is JavaScript for not having a Date implementation like every other freaking major language in the world.

  • Neither Gilbert nor Sullivan (unregistered)
    He was the very model of an enlightened modern-day senior web developer
    Dammit. Now I've got The Pirates of Penzance running through my head. Thanks.
  • KarelI (unregistered)

    Fortunately he didn't realize there are 30-day months and leap years :-)

  • Bob (unregistered) in reply to Patrick Bell

    Woah, sensitive type. Bit too close to the bone, huh?

  • Mutt (unregistered)

    People still use Experts Exchange?

  • Tasty (unregistered) in reply to barfoo
    barfoo:
    Obviously you lack creativity. The worse version would involve inputting the date in Julian and writing a routine to convert it to Gregorian.

    I'd much rather use Julian Days than the Gregorian calendar. They're much more accurate.

  • bewbs (unregistered) in reply to Patrick Bell

    you mad bro?

    [image]
  • ¯\(°_o)/¯ I DUNNO LOL (unregistered)

    TRWTF is that he didn't ask // string to int pretty please

    At least the year field is wide enough for Y10K.

  • Anon (unregistered) in reply to Mutt
    // set StartYear to 2010 so we don't goof up the loop logic

    I think that ship has sailed...

  • anony-mouse (unregistered)

    It's bad enough he had retarded practices, but he didn't have a logical understanding of programming.

    I suppose GlobalVars.Day = parseInt($('#DaySelect').val()) would have been too easy; case statement clearly necessary.

  • (cs) in reply to Patrick Bell
    Patrick Bell:
    Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

    <<snip>>

    plonk

    Sincerely, Patrick

    Work on C++ started in 1979. So it could not have "held the state of the art in software back by several decades".

    Only by three decades.

    So far.

  • (cs) in reply to Patrick Bell
    Patrick Bell:
    Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

    While you're right that C is a horrible language and should never have been allowed to inflict its descendants upon the world, particularly after 1989 when the Morris Worm taught us that it was completely unsuited to development in any environment that came with security requirements, that really doesn't have anything to do with today's article, and it doesn't make the code any less horrible.

  • (cs)

    This code is no excuse for being in field of computer programming.

  • qbolec (unregistered) in reply to ubersoldat
    ubersoldat:
    This is why college education is broken. They teach you so many things, except to look at the API.

    I would love to work in place that:

    1. hires only graduates of CS as web developers
    2. does not depend heavily on "designs" provided by Photo Shop artists as a GUI specs

    until then, I must say, that sadly, but we have developed more than one date-picker "control" even though some us knew that there is a plugin for that.

    JPEG-driven development is my everyday nightmare. I believe the problem is that JPEGs say 1000 words to upper managment, while software architects just say a lot of sophisticated words which are hard to comprehend. What I believe is necessary is to develop a visual language in which architects could express their thoughts to managment. I am not talking about UML -- it's too complicated. Look for instance at the domain of real Architecture (that one which deals with buildings) : architects in that area olways provide visualisations, beautiful pictures, perspectives, and so on. CS lacks this kind of visual language :(

  • myName (unregistered)

    It could have been written at a place which doesn't allow the use of any third party software other than the approved list.

  • C-Derb (unregistered)

    I'm calling shenanigans.

    There's no way you could have more than a week of web development experience and not have the thought ever cross your mind to simply start the select lists with <option value="<b>0</b>"></option>.

  • (cs)

    I love this Mayan calendar implementation! 2013? There is no 2013!!!

  • Anon (unregistered) in reply to D-Coder
    D-Coder:
    Work on C++ started in 1979. So it could not have "held the state of the art in software back by several decades".

    Only by three decades.

    So far.

    Wrong.

    http://xkcd.com/1070/

  • M (unregistered) in reply to D-Coder
    D-Coder:
    Patrick Bell:
    Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

    <<snip>>

    plonk

    Sincerely, Patrick

    Work on C++ started in 1979. So it could not have "held the state of the art in software back by several decades".

    Only by three decades.

    So far.

    Cue the obligatory xkcd reference, which happens to be today's comic!

    http://xkcd.com/1070/

  • Dave (unregistered) in reply to ubersoldat
    ubersoldat:
    TRWTF is JavaScript for not having a Date implementation

    Did you really just say that?

  • Anon (unregistered) in reply to M
    M:
    Cue the obligatory xkcd reference, which happens to be today's comic!

    http://xkcd.com/1070/

    TRWTF is people who claim to be programmers but don't read xkcd every day.

  • C-Derb (unregistered) in reply to shoeboy
    shoeboy:
    I love this Mayan calendar implementation! 2013? There is no 2013!!!

    I thought the same thing. Why go to all the trouble of dynamically populating the the Year selector when the "validation" is limited to 2011 and 2012, unless you know something?

                // set query filter based on selected value
                switch (GlobalVars.SelectedIndex) {
                    case 2:
                        {
                            GlobalVars.Year = '2011';
                            break;
                        }
                    case 3:
                        {
                            GlobalVars.Year = '2012';
                            break;
                        }
                }
    
  • Mike (unregistered)
    happily and cluelessly producing oceans of spaghetti code so bad that even Olive Garden wouldn't serve it
    That would have been wittier without "code".
  • Karel (unregistered) in reply to Patrick Bell

    Hi Patrick,

    Nice one and you're right. But that's no reason to leave. There is good stuff too here.

    Cheers

  • Nagesha (unregistered)

    I am telling that expertsexchange is site what is producing the very very best results in Hyderabad.

  • n_slash_a (unregistered)

    The ONLY good thing about that code is at least the comments were polite

    Original Article:
    // string to int please GlobalVars.SelectedIndex = parseInt(GlobalVars.SelectedIndex);
  • wonk (unregistered) in reply to Mutt
    Mutt:
    People still use Expert Sexchange?

    FTFY

  • dogmatic (unregistered)

    The real wtf is that he doesn't take into account for leap years. Amiright?

  • TurdCrawler (unregistered) in reply to mrfr0g
    mrfr0g:
    Patrick Bell:
    Because web developers are the only programmers who write horribly mangled code, amirite? Please. And yet it is taboo to say that C/C++ have held the state of the art in software back by several decades due to their extreme low-level concepts and lack of portability?

    Dear Daily WTF,

    I came for the lulz, and left because of the sickening elitism among your submitters and commentors whose lives are now so devoid of meaning that the only pleasure they get is derived from heckling the less gifted.

    Enjoy your passive aggressive snickering and your tiny cubicles while you hide from doing real work.

    plonk

    Sincerely, Patrick

    Hey congratulations! You just got the point of this website, to make fun of poorly written code. Today it is a javascript WTF, tomorrow it might be c/c++, Java, classic ASP, or really anything else "code" related.

    I am a Web Developer, have been for a number of years and I can say with certainty that the code posted today is terrible, and deserves to be made fun of.

    Dang! Before he left, we should have asked for some of his well-written code (to make fun of while we hide in our cubicles avoiding work)!

  • dogmatic (unregistered) in reply to Kasper
    Kasper:
    There is not much reason to be using javascript in the first place. That page could have worked just as fine without any javascript. The only thing that javascript could really do for such a page is to present an error message to the user slightly faster, if the input is inconsistent (like specifying the 30th of February or such).

    You are going to need validation on the server side anyway. As a user I'd much rather see a solution that only validates on the server side than one, that does a poor job of validating on the client side.

    You must provide both server side and client side evaluation else run the risk of being branded a lazy developer.

  • qwerty (unregistered)

    // get current date and time from server $.getJSON('/GetDateTime)', null, function (data) {

    wow.

  • F (unregistered) in reply to Anon
    Anon:
    M:
    Cue the obligatory xkcd reference, which happens to be today's comic!

    http://xkcd.com/1070/

    TRWTF is people who claim to be programmers but don't read xkcd every day.

    TRWTF is people who claim to be readers of xkcd but haven't noticed it only appears three times a week.

  • F (unregistered) in reply to Anon
    Anon:
    M:
    Cue the obligatory xkcd reference, which happens to be today's comic!

    http://xkcd.com/1070/

    TRWTF is people who claim to be programmers but don't read xkcd every day.

    TRWTF is people who claim to be readers of xkcd but haven't noticed it only appears three times a week.

  • Tom (unregistered)

    That is an elegant and beautiful solution to a completely non-existent problem.

  • Darth Paul (unregistered) in reply to Tim
    Tim:
    Once you understand that, client-scripted validation is merely sugar to help the babies who don't know how to enter dates yet.

    Or tar to hinder those who do.

  • (cs) in reply to F
    F:
    Anon:
    M:
    Cue the obligatory xkcd reference, which happens to be today's comic!

    http://xkcd.com/1070/

    TRWTF is people who claim to be programmers but don't read xkcd every day.

    TRWTF is people who claim to be readers of xkcd but haven't noticed it only appears three times a week.

    Who cares how often it appears, they still read it everyday. Just like I come here everyday but it isn't updated every day.

  • (cs)

    To be fair, most date selector UIs are incredibly slow and clunky to use. They are mostly useful for figuring out a date that you aren't sure about, but they're often quite painful. If you already have the date in mind then typing it is usually far easier. A smart text box that turns anything you type into a known date would be handy. Better than a "date picker", as they're generally called. A calendar view is useful for associating days with weeks or counting days, but not much else...

    Also, JavaScript reliance is evil. Also, that code is really bad...

Leave a comment on “Date Selector of the Damned”

Log In or post as a guest

Replying to comment #383348:

« Return to Article