• Uncle Al (unregistered) in reply to Jay
    Jay:
    Seriously curious:
    I will soon be looking for a job as a programmer. Do you really need no skills to get one?

    I recently had to modify an existing system, and as I reviewed the code, I was incredibly impressed at how the authors managed to get this thing to mostly work through shear diligence and hard work, despite an obvious total lack of any skill or talent.

    "Shear" diligence -- is that where you keep on using cut-and-paste until the code works? :-)

  • Juenemann (unregistered) in reply to nobulate

    My interpretation: It's Charlie Brown's shirt, which means that it takes a blockhead to produce this sort of code.

    nobulate:
    This code is designed for something.. bigger. Any noob can just call:
    return months[$inter];
    No this was designed like this, it has a purpose. I think I found that purpose: copy/paste the code and zoom out, it makes a pattern... Now if we can just find out what it all means.

    [image]

  • Dogga (unregistered)

    Obviously an Aussie Programmer:

    "The array seems to need an extra moth before January..."

    "Ah, She'll be Apples, don't worry 'bout it"

  • stu (unregistered) in reply to nobulate
    nobulate:
    This code is designed for something.. bigger. Any noob can just call:
    return months[$inter];
    No this was designed like this, it has a purpose. I think I found that purpose: copy/paste the code and zoom out, it makes a pattern... Now if we can just find out what it all means.

    [image]

    YES! It looks like the Tour De France!

  • Bobby (unregistered)

    I know the solution to this code snippet!!! He needs to use a switch statement instead of all the if's and have a default to return an error msg if the supplied index is not found or they pass in 0!

  • Dave (unregistered)

    I wonder if it's just an odd coincidence that got 4 spam (phishing) emails today welcoming me to "Joomla"

  • Andrew Sachs (unregistered) in reply to frits
    frits:
    the beholder:
    Robyrt:
    And why is there a period after May?
    Because it's an abbreviation of the month named Mayonnaise. Which is fortunately four months apart from Apples, because apples and mayonnaise don't go well together

    Apparently you've never heard of Waldorf salad.

    ...must ... resist ... fawlty towers reference ...

    Captcha: veniam. I came, I saw, I poisoned.

  • Andrew Sachs (unregistered) in reply to Andrew Sachs

    Correct - I didn't bother to read all the previous comments. Well spotted.

    Captcha: a word I have to type to prove I'm not a robot. Nobody cares what word it is.

  • PinkyAndTheBrainFan187 (unregistered) in reply to frits
    frits:
    the beholder:
    Robyrt:
    And why is there a period after May?
    Because it's an abbreviation of the month named Mayonnaise. Which is fortunately four months apart from Apples, because apples and mayonnaise don't go well together

    Apparently you've never heard of Waldorf salad.

    TRWTF

  • some guy (unregistered)

    What's wrong with this:

    <? //convert month number to month name
    function monther($inter){
    $months = array("Apples", "Jan.", "Feb.", "Mar.", "Apr.",
     "May", "Jun.", "Jul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec.");
    
    if(!isset($months[$inter]))
    $inter=0;
    
    return $months[$inter];
    }
    // end converting month
    ?>
    
  • Mark J. (unregistered) in reply to the beholder
    the beholder:
    Robyrt:
    And why is there a period after May?
    Because it's an abbreviation of the month named Mayonnaise. Which is fortunately four months apart from Apples, because apples and mayonnaise don't go well together
    Why not? Haven't you ever had a Waldorf salad?
  • Soleil Levant (unregistered) in reply to bl@h
    bl@h:
    function monther($inter), did anyone ready this as 'mother' ?

    Someone or something did, or there wouldn't be a trackback to "How to cope with back pain during pregnancy".

  • (cs)

    What about Octember and Marchuary?

  • Alargule (unregistered) in reply to nobulate
    nobulate:
    This code is designed for something.. bigger. Any noob can just call:
    return months[$inter];
    No this was designed like this, it has a purpose. I think I found that purpose: copy/paste the code and zoom out, it makes a pattern... Now if we can just find out what it all means.

    [image]

    Looks like a bunch Space Invaders to me...

    captcha: tristique. It sure is, zut alors!

  • (cs) in reply to Scott
    Scott:
    Indenting code like that is for streamlining - it makes it faster.

    Well, that's partly true. It's faster during the second half of the year because it's downhill. However, climbing the mountain in the first half of the year will offset any gains you might see. Fortunately, the second half of the year is 2 or 3 days longer than the first (depending on leap year) resulting in a 0.7% average improvement.

  • -anon for this (unregistered)

    Did someone punch him in the face before he created this monster? Ith muth hafh been painfufh...

  • anonymous (unregistered) in reply to Michael

    Yes he did it is the Arrow Like Pattern

  • al (unregistered)

    crap

  • a helping hand (unregistered) in reply to Rajendra Kumar
    Rajendra Kumar:
    Dear colleague, I have requirements for this exact code. Except I needing the months in Arabic or Hindi. Could you pls post the code? Also, I have doubts about JUnit testing for this. Could you pls provide this as well? It's urgent! pls! Tnanks in advance.

    Sure, here you go mate:

    <? //convert month number to month name
    function monther($inter){
    $months = array("Beards", "Cha.", "Vai.", "Jya.", "Asa.", "Sra.", "Bha.", "Asv.", 
                    "Kar.", "Marg.", "Pau.", "Mag.", "Pha.");
            if($inter == 1){
                echo $months[1];
                } else if($inter == 2){
                        echo $months[2];
                        } else if($inter == 3){
                                echo $months[3];
                                } else if($inter == 4){
                                        echo $months[4];
                                        } else if($inter == 5){
                                                echo $months[5];
                                                } else if($inter == 6){
                                                         echo $months[6];
                                                         } else if($inter == 7){
                                                                 echo $months[7];
                                                } else if($inter == 8){
                                                         echo $months[8];
                                        } else if($inter == 9){
                                                 echo $months[9];
                                } else if($inter == 10){
                                         echo $months[10];
                        } else if($inter == 11){
                                 echo $months[11];
                } else if($inter == 12){
                         echo $months[12];
            }
    }
    // end converting month
    ?>
  • jc (unregistered) in reply to Rajendra Kumar

    Easy: Just write a routine that connects to Google Translate, passes it the output of this routine, and reads back the result.

  • JonsJava (unregistered)

    I got bored, and realized I know how to "script" in PHP, so that means one thing: lets show the right way, and the so wrong way of doing this (if you MUST have a function that outputs an array of months). Mine isn't right still, but it was fun trying things the "wrong right" way:

    <?php
    /* The "Wrong right" way */
    function getMonths(){
    	$monts = range(1, 12);
    	foreach ($monts as $val){
    		$out[] = date("m",strtotime("2010-{$val}-01"));
    	}
    	return $out;
    }
    /* This one is just as acceptable as the first */
    function getMonths2(){
    	$months = array(1=>"Jan",2=>"Feb",3=>"Mar",4=>"Apr",5=>"May",6=>"Jun",7=>"Jul",8=>"Aug",9=>"Sep",10=>"Oct",11=>"Nov",12=>"Dec");
    	return $months;
    }
    /* More like the coders way */
    function getMonths3(){
    	$num_of_months = 12; // In case that ever changes
    	$num_of_days = "30.4166666666"; // average
    	$num_of_days_in_year = $num_of_months * $num_of_days;
    	$months_array = range(1, $num_of_months);
    	/* at this point, I forgot where I was going with this */
    	return "Oh, shiny";
    }
    print_r(getMonghs());
    ?>
    

    CAPTCHA: validus. So close to being validated

  • Chris (unregistered) in reply to Rajendra Kumar

    Try this:

    $months = array("Tuffah", "Muharram", "Safar", "Rabi Al Awwal", "Rabi Al Thani", "Jumada Al Awwal", "Jumada Al Thani", "Rajab", "Sha'ban", "Ramadan", "Shawwal", "Dhul Qa'dah", "Dhul Hijjah");

  • the beholder (unregistered) in reply to frits
    frits:
    the beholder:
    Robyrt:
    And why is there a period after May?
    Because it's an abbreviation of the month named Mayonnaise. Which is fortunately four months apart from Apples, because apples and mayonnaise don't go well together

    Apparently you've never heard of Waldorf salad.

    Thanks for reminding me how apples and mayonnaise don't go well together.

    I rest my case, your honor.

  • C (unregistered) in reply to Marc B
    Marc B:
    Jay:
    Buddy:
    I like the period after May, and how September is abbreviated to four characters while the other months are abbreviated three characters.
    And if it's okay to appreviate September to 4 letters, why bother to abbreviate June and July at all?
    Because then he'd need 5 characters (for "June." and "July.") -- look at "May.".

    This WTF is entertaining on so many levels...

    Umm... "Sept." also needs 5 chars! Your point?

  • (cs) in reply to the beholder
    the beholder:
    frits:
    the beholder:
    Robyrt:
    And why is there a period after May?
    Because it's an abbreviation of the month named Mayonnaise. Which is fortunately four months apart from Apples, because apples and mayonnaise don't go well together

    Apparently you've never heard of Waldorf salad.

    Thanks for reminding me how apples and mayonnaise don't go well together.

    I rest my case, your honor.

    Bah, whatever. There's no accounting for taste.

  • iMalc (unregistered)

    I don't see anyone saying that this guy was bananas!

  • keeno (unregistered) in reply to frits
    frits:
    Aaron:
    No doubt the original code was just a bunch of if/else/return statements; somebody caught wind of this and told the code monkey, "you idiot, use an array!" And he did...

    Right...Because an array is the right answer.

    No, "42" is the answer - the array just gets you there sooner.

  • Cbuttius (unregistered)

    Apples is a great month to do this:

    http://thedailywtf.com/Articles/Nobody-Does-Business-on-December-31st!.aspx

    By the way, why is September so special that its abbreviation has 4 letters?

    captcha: decet

  • (cs) in reply to Cbuttius
    Cbuttius:
    Apples is a great month to do this:

    http://thedailywtf.com/Articles/Nobody-Does-Business-on-December-31st!.aspx

    By the way, why is September so special that its abbreviation has 4 letters?

    captcha: decet

    http://thedailywtf.com/Articles/Nobody-Does-Business-on-December-31st!.aspx

  • (cs) in reply to keeno
    keeno:
    frits:
    Aaron:
    No doubt the original code was just a bunch of if/else/return statements; somebody caught wind of this and told the code monkey, "you idiot, use an array!" And he did...

    Right...Because an array is the right answer.

    No, "42" is the answer - the array just gets you there sooner.

    It looks like you're trying to be funny. Would you like help?

  • Dan (unregistered) in reply to BramSmulders
    BramSmulders:
    Everyone knows it should have been 'App.' instead of 'Apples'.

    Apples is the shortened version of Applebys. Obviously a shameless marketing ploy, to get us to spend a whole month going to their restaurant.

  • (cs) in reply to Don
    Don:
    frits:
    the beholder:
    ... apples and mayonnaise don't go well together

    Apparently you've never heard of Waldorf salad.

    I have heard of Waldorf salad (my wife makes it every year to go with Thanksgiving dinner) and I'd have to agree with the beholder.

    Have her substitute yogurt for the mayonaise. Much, much better.

  • Lol (unregistered)

    Looks like he copied the array code from w3schools.

  • Medinoc (unregistered)

    Looks like a good Developmestuction environment...

  • ~~ (unregistered)

    Oh, this is just PHP. Have you ever seen high-quality, mission-critical airbag ECU code? Like this:

    enum index {
     one, two, three, four, five, six} idx;
    int array[six+1];
    ...
    array[idx] = ...;

    or (scattered through the code under many names):

    BOOL very_readable_function(BOOL param)
    {
        BOOL ret = FALSE;
        if (FALSE == param)
        {
             ret = FALSE;
        }
        else
        {
             ret = TRUE;
        }
        return ret;
    }
  • (cs)

    Am I the only one who sees a retro starship there? With a laser on the left side?

  • Carlos (unregistered)

    Indeed this is wrong, php's "elseif" is way more cost effective than "else if". lol

  • Junaldo[0] (unregistered) in reply to keeno
    keeno:
    frits:
    Aaron:
    No doubt the original code was just a bunch of if/else/return statements; somebody caught wind of this and told the code monkey, "you idiot, use an array!" And he did...

    Right...Because an array is the right answer.

    No, "42" is the answer - the array just gets you there sooner.

    Sooner. As in "in 43 iterations..."

    Captcha: inhibeo - Suppressing emotions in a city near you! Tickets on sale now.

  • Prashant (unregistered) in reply to Chris

    He needed Hindi too:

    $months = array("सेब", "जनवरी", "फ़रवरी", "मार्च", "अप्रेल", "मई", "जून", "जुलई", "अगस्त", "सितंबर", "अक्टूबर", "नवंबर", "दिसंबर");

  • Friday (unregistered)

    I've been wondering: would the abbreviation for the month of Apples be App or Apl?

Leave a comment on “The 0th Month”

Log In or post as a guest

Replying to comment #:

« Return to Article