• (cs) in reply to usitas
    usitas:
    Kivi:
    There are calendars where the number of months changes from year to year. The Jewish calendar roughly alternates between 12 and 13 in order to synchronize between the cycle of new moons and the solar year.

    Not that that keeps this from being worse than failure though: the lack of a parameter to the function is highly suspicious.

    Not really related, but amusing: http://www.improbable.com/2011/10/14/ig-nobel-winner-writes-best-abstract-ever/. Best scientific abstract ever.

    When are all these religions out there finally get it: we have a globally used calendar, and stop using all other junk that relate to non-existing mythological creatures such as the god (deliberately lowecase)?

    I don't understand the question.

  • Spit Can - Make Weight (unregistered) in reply to Nagesh
    Nagesh:
    Many time year is having extra munth. I am on far left at last adhik mas festival.

    [image]

    I wasn't aware that high school was even available in India, yet I'm seeing an execution of the "High School Hero" headlock before my very eyes.

  • (cs) in reply to EatenByAGrue
    EatenByAGrue:
    usitas:
    When are all these religions out there finally get it: we have a globally used calendar, and stop using all other junk that relate to non-existing mythological creatures such as the god (deliberately lowecase)?

    By a "globally used calendar", you're talking about the one with:

    • a 7-day week from Genesis
    • days named after Tyr, Odin, Thor, Frig, and Saturn
    • months named after Janus, Mars, Maia, Juno, and the deified Julius and Augustus Because that clearly in no way involves mythological creatures.
    It's even worse than you think. Since the other two days are named after the Sun and the Moon, and the five you mention are also planet names (think of the Romance language versions), the days of the week are actually based on astrology.
  • Boog, I Am Your Father! (aka Behold The Return Of Zunesis!)! (unregistered) in reply to Foobar
    Foobar:
    "Twelve" is so strange because it is a word invented by elves. It is a subtle fairy revenge against the English.

    Now you know.

    I think the fairy revenge against the English was making them all fairies. Seriously, it's like, you whistle at some chick and all these guy's asses pop up in the air. I guess they're used to grasping their ankles. At least they have great hospitals for the reconstructive surgery when I'm done with them. And I only mean that half-sarcastically. The Her Royal Highness's Plastic Surgeons with wonders for my formerly average endowment. I could make a bitch elephant cry now!

    Arrrrggggggg!!! Even this elephant pussy is too fucking tight for me now!!! rrrrrrrrr!!! Oh! Oh! OOOOOOOOOOOOHHHHHHHHHHHHH YEEEEEEEAAAAAAAAHHHHHHHH!!!!

  • bloo (unregistered) in reply to ContraCorners
    ContraCorners:
    Unless, of course, you're using the Ethopian Calendar.

    http://www.tourismethiopia.org/

    Tour is meth iopia? that's as bad as pen island - the place for all your scribbling purchases.
  • siggi (unregistered)

    may i help?

    getDaysInLunarMonth = function () { return 28; }
    
    getDaysInWeek = function () { 
       var daysInLunarMonth = getDaysInLunarMonth();
       return daysInLunarMonth / 4;
    }
    

    [image] tricky isn't it?

  • Bldsquirrel (unregistered) in reply to MojoMonkeyfish
    MojoMonkeyfish:
    #DEFINE TWELVE = 12;
    

    function getMonthCountForSelectedYear() { return TWELVE; }

    There, I fixed it. Totally didn't account for twelve changing. Could have been a real pain in the butt.

    ...but 12 is a magic number you need:

    #DEFINE TWELVE = 12; #DEFINE MONTHS_IN_A_YEAR = TWELVE

    function getMonthCountForSelectedYear()

    {

    return MONTHS_IN_A_YEAR;

    }

  • Boog, I Am Your Father! (aka Behold The Return Of Zunesis!)! (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    me:
    Who is askimet?
    An evil, racist AI bent on stopping the dissemination of funny and/or applicable content.
    "Who Is Askimet?" The thrilling new feature film about a diabolical entity that random takes people's voices just as they become vitally necessary. Thruought the story, people are demanding to know the anwser to the titular phrase. Oh, and it's racist! Bwa-ha-ha-ha!!!

    "Who Is Askimet?" - Coming Halloween 2012, Scared Yet?

    Then later, we'll have "'Who's In My Ass?', I Meant!" - the thrilling new adult feature parody of the thrilling new feature film "Who Is Askimet?" concerning a diabolical interloper on a key scene where a naive, young pornographic actress is unable to ask who has begun penetrating her anus, as she was still blowing her co-star. The mystery persists until she's able to cough up that ebony footlong. Again, she persists: "Who's in my ass?, I meant". Who, indeed! Ha ha ha!

    "'Who's In My Ass?', I Meant!" - Cuming Christmas 2012, Scared Wet? Yeah? A little fear turns you on?

  • (cs) in reply to S&H IT
    S&H IT:
    To be fair, the Hebrew calendar sometimes has 13 months, depending on if it's a leap year. http://en.wikipedia.org/wiki/Hebrew_calendar#Names_of_months

    Hindu Calendar also having extra month. Hindu follow lunar cycle, so no leap year. but sometime leap month. ;)

  • (cs) in reply to Boog, I Am Your Father! (aka Behold The Return Of Zunesis!)!
    Boog:
    [stuff only one with a soul as demented as zunesis can write]
    What, no "invisible" comments? I'm disappointed...
  • Springer (unregistered) in reply to MojoMonkeyfish
    MojoMonkeyfish:
    #DEFINE TWELVE = 12;
    

    function getMonthCountForSelectedYear() { return TWELVE; }

    There, I fixed it. Totally didn't account for twelve changing. Could have been a real pain in the butt.

    /* OBSOLETED 
    #define ONE 1
    #define TWO (ONE+ONE)
    #define THREE (TWO+ONE)
    #define FOUR (TWO+TWO) //optimized to use TWO instead of ONE
    #define FIVE (FOUR+ONE)
    #define SIX (FOUR+TWO)
    #define SEVEN (FOUR+TWO+ONE) //Oh, now we are a geek...
    #define EIGHT (FOUR+FOUR) //more OPTIMIZATION
    #define NINE (EIGHT+ONE)
    #define TEN (EIGHT+TWO)
    #define ELEVEN (EIGHT+TWO+ONE)
    #define TWELVE (EIGHT+FOUR)
    *******  END OBOLETED *****/
    
    /***
     * The previous number definitions were inefficient, so we have 
    *optimised for maximum usefulness (we leave how not to do it above 
    *as an example for the n00bs who don't know better 
    */
    #define ONE 1
    #define TWO (ONE<<ONE)
    #define THREE (TWO+ONE)
    #define OLD_FOUR (TWO<<ONE)
    #define FOUR (ONE<<TWO) // Much better than TWO<<ONE
    #define FIVE (FOUR+ONE)
    #define SIX (FOUR+TWO)
    #define SEVEN (FOUR+TWO+ONE)
    #define OLD_EIGHT (ONE<<THREE) 
    #define EIGHT (FOUR<<ONE) //Could do ONE<<THREE, but better to use powers of two
    #define NINE (EIGHT+ONE)
    #define TEN (EIGHT+TWO)
    #define ELEVEN (EIGHT+TWO+ONE)
    #define TWELVE (EIGHT+FOUR)
    #define THIRTEEN (EIGHT+FOUR+ONE)
    #define FOURTEEN (EIGHT+FOUR+TWO)
    #define FIFTEEN (EIGHT+FOUR+TWO+ONE)
    #define OLDER_SIXTEEN (ONE<<FOUR)
    #define OLD_SIXTEEN (EIGHT<<ONE)
    #define SIXTEEN (FOUR<<TWO)
    </pre>
    

    No Magic numbers!!

  • Santa (unregistered) in reply to MojoMonkeyfish
    MojoMonkeyfish:
    Btw, why is twelve such a strange word to say and spell?
    Well, we used to have a base six notation where 6 was referred to as an elf. Twelve derives from Two Elves, but over time it has run together.

    I think eleven is related too....

  • Samoan Joe (unregistered) in reply to Ant
    Ant:
    Jon-Paul continues, "I particularly like the way you don't even have to pass in the selected year to still get the correct return value. It's such a shame this guy has left now as I need to write a function that calculates the number of days in any given week and he could've helped."
    Try asking the Samoans how many days there were last week!
    Like
  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    Boog:
    [stuff only one with a soul as demented as zunesis can write]
    What, no "invisible" comments? I'm disappointed...

    Disappointment is inevitable with life you are leading on Planet Earth. If you want to live blesed life, accept role of religion and follow it religiously.

  • Jim (unregistered) in reply to Nagesh
    Nagesh:
    On years with extra munth, Hindu calander is requiring appropriate secrifise.

    [image]

    The kid in the blue who you intend to sacrifice looks so Glum!!!

  • pedant (unregistered) in reply to Jack
    Jack:
    MojoMonkeyfish:
    Btw, why is twelve such a strange word to say and spell?

    Well, it's a hold-over from an old base-12 number system. That's why it's its own word, instead of "twoteen," or "ten-two," or something. I believe it's the same reason we have the word "dozen," and there are 12 inches in a foot. That probably doesn't answer your question, though...

    And yet you would think that "teen" derives from "ten" rather than "twelve"....

    Does that mean that pre-decimalization we got to twelve and then said "one one", "one two"....etc, and it was only with decimalization (where we kept eleven and twelve - why not, they're already words for such quantities - backward compatibility and all that) that we introduced thirteen etc...

  • Boog, I Am Your Father! (aka Behold The Return Of Zunesis!)! (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Boog:
    [stuff only one with a soul as demented as zunesis can write]
    What, no "invisible" comments? I'm disappointed...
    Oh, it's just never good enough, is it?!

    I slave over my keyboard for minutes at a time composing these treasures! And you just waltz in from work and throw it in my face!

    Hmm.. you know what? I think this is the perfect opportunity to tell you - your penis has never satisfied me! You know all those "orgasms" I've had. Well check out the finger quotes: they were fake!

    Our son has such a bigger dick than you - he must have gotten from my side of the family as from what I've seen, my father must have been at least 1/8th donkey! Why'd I have to carry the big dick gene, I'm the woman!? Shouldn't you have the huge cock gene, Baby Dick! Sperm Fail! AAAAAAAAA!!!!

  • (cs) in reply to Springer
    Springer:
    MojoMonkeyfish:
    #DEFINE TWELVE = 12;
    

    function getMonthCountForSelectedYear() { return TWELVE; }

    There, I fixed it. Totally didn't account for twelve changing. Could have been a real pain in the butt.

    /* OBSOLETED 
    #define ONE 1
    #define TWO (ONE+ONE)
    #define THREE (TWO+ONE)
    #define FOUR (TWO+TWO) //optimized to use TWO instead of ONE
    #define FIVE (FOUR+ONE)
    #define SIX (FOUR+TWO)
    #define SEVEN (FOUR+TWO+ONE) //Oh, now we are a geek...
    #define EIGHT (FOUR+FOUR) //more OPTIMIZATION
    #define NINE (EIGHT+ONE)
    #define TEN (EIGHT+TWO)
    #define ELEVEN (EIGHT+TWO+ONE)
    #define TWELVE (EIGHT+FOUR)
    *******  END OBOLETED *****/
    
    /***
     * The previous number definitions were inefficient, so we have 
    *optimised for maximum usefulness (we leave how not to do it above 
    *as an example for the n00bs who don't know better 
    */
    #define ONE 1
    #define TWO (ONE<<ONE)
    #define THREE (TWO+ONE)
    #define OLD_FOUR (TWO<<ONE)
    #define FOUR (ONE<<TWO) // Much better than TWO<<ONE
    #define FIVE (FOUR+ONE)
    #define SIX (FOUR+TWO)
    #define SEVEN (FOUR+TWO+ONE)
    #define OLD_EIGHT (ONE<<THREE) 
    #define EIGHT (FOUR<<ONE) //Could do ONE<<THREE, but better to use powers of two
    #define NINE (EIGHT+ONE)
    #define TEN (EIGHT+TWO)
    #define ELEVEN (EIGHT+TWO+ONE)
    #define TWELVE (EIGHT+FOUR)
    #define THIRTEEN (EIGHT+FOUR+ONE)
    #define FOURTEEN (EIGHT+FOUR+TWO)
    #define FIFTEEN (EIGHT+FOUR+TWO+ONE)
    #define OLDER_SIXTEEN (ONE<<FOUR)
    #define OLD_SIXTEEN (EIGHT<<ONE)
    #define SIXTEEN (FOUR<<TWO)
    </pre>
    

    No Magic numbers!!

    Only n00bs use + when they could use |

  • bleh (unregistered) in reply to ContraCorners
    ContraCorners:
    Unless, of course, you're using the Ethopian Calendar.

    http://www.tourismethiopia.org/

    Or these dudes manage to get the Hanke-Henry Permanent Calendar to catch on...

    http://www.universetoday.com/92306/new-year-new-calendar-but-johns-hopkins-scholars-say-we-need-a-permanent-edition/

  • Video Idea (unregistered) in reply to Mason Wheeler
    Mason Wheeler:
    I used to write functions like that, but then I took an arrow in the knee.
    I have an idea for a YouTube video, but no idea how to make it.

    Gather up video clips of 20 or 30 guards in Skyrim giving the "arrow to the knee" bit, and put them back to back.

    Immediately after this, add the clip in Terminator 2 where Arnold is shooting all of the guards in their kneecaps.

  • (cs) in reply to Kivi
    Kivi:
    There are calendars where the number of months changes from year to year. The Jewish calendar roughly alternates between 12 and 13 in order to synchronize between the cycle of new moons and the solar year.

    Not that that keeps this from being worse than failure though: the lack of a parameter to the function is highly suspicious.

    Not really related, but amusing: http://www.improbable.com/2011/10/14/ig-nobel-winner-writes-best-abstract-ever/. Best scientific abstract ever.

    For terseness, what about Frank Nelson Cole's lecture in which he demonstrated that:

    2^67 - 1 = 147573952589676412927 = 761838257287 × 193707721

    without uttering a word?

  • (cs) in reply to AP2
    AP2:
    Well, this code is obviously buggy; it didn't work at Kodak.

    The reason that never caught on is because every single month would then contain a Friday the 13th. Yeah, the superstitious peasants who get voted into office would have adopted that as the national calendar, defly.

  • (cs) in reply to MojoMonkeyfish
    MojoMonkeyfish:
    Btw, why is twelve such a strange word to say and spell?

    So as to make "twelve plus one" an anagram of "eleven plus two".

    Why are "one" and "two" similarly? They should be "wun" and "too".

  • (cs) in reply to Boog, I Am Your Father! (aka Behold The Return Of Zunesis!)!
    Boog:
    Foobar:
    "Twelve" is so strange because it is a word invented by elves. It is a subtle fairy revenge against the English.

    Now you know.

    I think the fairy revenge against the English was making them all fairies. Seriously, it's like, you whistle at some chick and all these guy's asses pop up in the air. I guess they're used to grasping their ankles. At least they have great hospitals for the reconstructive surgery when I'm done with them. And I only mean that half-sarcastically. The Her Royal Highness's Plastic Surgeons with wonders for my formerly average endowment. I could make a bitch elephant cry now!

    Arrrrggggggg!!! Even this elephant pussy is too fucking tight for me now!!! rrrrrrrrr!!! Oh! Oh! OOOOOOOOOOOOHHHHHHHHHHHHH YEEEEEEEAAAAAAAAHHHHHHHH!!!!

    You do know that eleven in German is elf?

  • Tud (unregistered) in reply to DMAA

    In Haskell it's easier:

    monthcountforyear 0 = 12
    monthcountforyear n
        | n > 0 = monthcountforyear (n - 1)
        | n < 0 = monthcountforyear (n + 1)
    

    (Well no, I have never written anything over 6 lines long in Haskell, why do you ask?)

  • Tud (unregistered) in reply to Matt Westwood
    Matt Westwood:
    MojoMonkeyfish:
    Btw, why is twelve such a strange word to say and spell?

    So as to make "twelve plus one" an anagram of "eleven plus two".

    Why are "one" and "two" similarly? They should be "wun" and "too".

    Because English.

  • (cs) in reply to Tud
    Tud:
    Matt Westwood:
    MojoMonkeyfish:
    Btw, why is twelve such a strange word to say and spell?

    So as to make "twelve plus one" an anagram of "eleven plus two".

    Why are "one" and "two" similarly? They should be "wun" and "too".

    Because English.

    English is a Germanic language; Being derived from German, and have you looked at German lately?

  • Cheong (unregistered)

    FYI, for a number of calendar, some years do have leap month and month count don't necessary even across the years.

  • (cs) in reply to MojoMonkeyfish
    MojoMonkeyfish:
    Btw, why is twelve such a strange word to say and spell?

    Not nearly as strange to say and spell as "twaddle".

  • Son Of Thor (unregistered)

    Well I like forward thinking with descovery of Kepler 20 which is in the habital zone of its solar system it most likely dont have twelve mounth in the year and Kepler 20lings may want to run the software

  • (cs) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    EatenByAGrue:
    By a "globally used calendar", you're talking about the one with: * a 7-day week from Genesis * days named after Tyr, Odin, Thor, Frig, and Saturn * months named after Janus, Mars, Maia, Juno, and the deified Julius and Augustus Because that clearly in no way involves mythological creatures.
    It's even worse than you think. Since the other two days are named after the Sun and the Moon, and the five you mention are also planet names (think of the Romance language versions), the days of the week are actually based on astrology.
    It's even worse than you think. In Japanese the days of the week have names that essentially read "Sun-day", "Moon-day", "Fire-day", "Water-day", "Wood-day", "Gold-day" and "Earth-day". And since in Japanese the planet Mercury is "Water-star", Venus is "Gold-star", Mars is "Fire-star", Jupiter is "Wood-star" and Saturn is "Earth-star", there's a one-to-one correspondence between the days of the week and the astrological planets.
  • Gunslinger (unregistered)

    If they ever take my suggestion to move to a rational 28 day/13 month calendar, then this function will be useful. You will rue the day you mocked him!

  • (cs) in reply to Gunslinger
    Gunslinger:
    If they ever take my suggestion to move to a rational 28 day/13 month calendar, then this function will be useful. You will rue the day you mocked him!

    "Useful"? It'll be wrong!

  • corroded (unregistered) in reply to J.R.R. Trollkein
    J.R.R. Trollkein:
    Foobar:
    "Twelve" is so strange because it is a word invented by elves. It is a subtle fairy revenge against the English.

    Now you know.

    This makes perfect sense.

    Good thing we didn't anger the dwarves. Counting "Ten, Eleven, Twarf" would just be silly.

    You mean "Ten, Dwarven, Twdwarve"?

  • CFM (unregistered) in reply to PiisAWheeL

    Actually both English and German are derived from Proto-Germanic. English is no more derived from German than humans are derived from chimpanzees.

  • Lost (unregistered)

    He forgot about Undecimber

  • undefined (unregistered) in reply to da Doctah
    da Doctah:
    PedanticCurmudgeon:
    EatenByAGrue:
    By a "globally used calendar", you're talking about the one with: * a 7-day week from Genesis * days named after Tyr, Odin, Thor, Frig, and Saturn * months named after Janus, Mars, Maia, Juno, and the deified Julius and Augustus Because that clearly in no way involves mythological creatures.
    It's even worse than you think. Since the other two days are named after the Sun and the Moon, and the five you mention are also planet names (think of the Romance language versions), the days of the week are actually based on astrology.
    It's even worse than you think. In Japanese the days of the week have names that essentially read "Sun-day", "Moon-day", "Fire-day", "Water-day", "Wood-day", "Gold-day" and "Earth-day". And since in Japanese the planet Mercury is "Water-star", Venus is "Gold-star", Mars is "Fire-star", Jupiter is "Wood-star" and Saturn is "Earth-star", there's a one-to-one correspondence between the days of the week and the astrological planets.

    It's better than you think. In Russian days of week have names "the day after day without work" (Понедельник, Monday), "second day after day without work" (Вторник, Tuesday), "day at the middle of work week" (Среда, Wednesday), "fourth day" (Четверг, Thursday), "fifth day!!!" (Пятница, Friday), "Shabbat" (Суббота, Saturday) and "Resurrection" (Воскресенье, Sunday).

  • cappeca (unregistered) in reply to MojoMonkeyfish
    MojoMonkeyfish:
    #DEFINE TWELVE = 12;
    

    function getMonthCountForSelectedYear() { return TWELVE; }

    There, I fixed it. Totally didn't account for twelve changing. Could have been a real pain in the butt.

    +1 No magic numbers!

  • Going half way (unregistered) in reply to Maurits

    Surely, that's all a step in the right direction, but still ridden with magic stuff and not the implemention of Zermelo-Fraenkel which I expected from you. I gave you everything i.e. zero and what do I get in return? You can do better guys!

  • makes sens (unregistered) in reply to undefined

    So in Russia months count you?

  • Bas (unregistered)

    This looks like a fail attempt at a constant.

  • Nagesh (unregistered) in reply to Nagesh
    Nagesh:
    S&H IT:
    To be fair, the Hebrew calendar sometimes has 13 months, depending on if it's a leap year. http://en.wikipedia.org/wiki/Hebrew_calendar#Names_of_months

    Hindu Calendar also having extra month. Hindu follow lunar cycle, so no leap year. but sometime leap month. ;)

    I am saying that already, idiot.

  • Captain Boolean (unregistered)
    int getMonthCountForSelectedYear(int year)
    {
        DateTime tmpDate = new DateTime(year, 1, 1);
        IList<DateTime> allDaysInYear = new List<DateTime>();
        while (tmpDate.Year == year)
        {
            allDaysInYear.Add(tmpDate);
            tmpDate = tmpDate.AddDays(1);
        }
        return allDaysInYear.Select(d => d.Month).Distinct().Count();
    }

    Future proofed?

  • SonicLover (unregistered)

    I can actually defend this.

    This function, when originally written, was a lot more complicated and actually calculated how many months were in the given year. Most likely some idiot who didn't realize there were always 12 months in the year; I've seen enough TDWTF to know those are commonplace in these situations. Later someone noticed it always returned 12, and simplified it as such, and then deleted the year parameter in the function call because it wasn't used.

    As for why the function itself wasn't deleted, I'm sure there's a reason for that, too.

  • Jens (unregistered)

    Reason: A static code analysis tool complained about a magic number.

  • golddog (unregistered) in reply to undefined
    undefined:
    da Doctah:
    PedanticCurmudgeon:
    EatenByAGrue:
    By a "globally used calendar", you're talking about the one with: * a 7-day week from Genesis * days named after Tyr, Odin, Thor, Frig, and Saturn * months named after Janus, Mars, Maia, Juno, and the deified Julius and Augustus Because that clearly in no way involves mythological creatures.
    It's even worse than you think. Since the other two days are named after the Sun and the Moon, and the five you mention are also planet names (think of the Romance language versions), the days of the week are actually based on astrology.
    It's even worse than you think. In Japanese the days of the week have names that essentially read "Sun-day", "Moon-day", "Fire-day", "Water-day", "Wood-day", "Gold-day" and "Earth-day". And since in Japanese the planet Mercury is "Water-star", Venus is "Gold-star", Mars is "Fire-star", Jupiter is "Wood-star" and Saturn is "Earth-star", there's a one-to-one correspondence between the days of the week and the astrological planets.

    It's better than you think. In Russian days of week have names "the day after day without work" (Понедельник, Monday), "second day after day without work" (Вторник, Tuesday), "day at the middle of work week" (Среда, Wednesday), "fourth day" (Четверг, Thursday), "fifth day!!!" (Пятница, Friday), "Shabbat" (Суббота, Saturday) and "Resurrection" (Воскресенье, Sunday).

    I don't roll on Shabbat!

    (OK, not quite the quote...)

  • (cs)
    function getMonthCountForSelectedYear(year)
    {
        var counts = {};
    
        for(var i=0; i<99999; i++)
        {
            counts["" + i] = 12;
        }
    
        var count = counts["" + year];
    
        if(typeof count != "undefined")
        {
            return count;
        }
    
        return "file not found";
    }
  • callcopse (unregistered)

    You might get different numbers of days in the week if you live in Samoa, last week you only got 6.

  • Anon (unregistered) in reply to Mason Wheeler

    That wasn't funny after the first day. Please stop.

  • Boog, I Am Your Father! (aka Behold The Return Of Zunesis!)! (unregistered) in reply to Anon
    Anon:
    Mason Wheeler:
    I used to write functions like that, but then I took a cock in the ass.
    That wasn't funny after the first day. Please stop.
    Better?

Leave a comment on “Nondeterministic Months”

Log In or post as a guest

Replying to comment #:

« Return to Article