|
|
|
| Hurry! Enter The Daily WTF's OMGWTF2 Contest by June 28th! - Prizes! Fame! Trophies! Do your worst: http://omg2.thedailywtf.com/ |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
FOOLS!!!!
BWAAHAHAHA!!! (FRIST) |
|
Unless, of course, you're using the Ethopian Calendar.
http://www.tourismethiopia.org/ |
|
I used to write functions like that, but then I took an arrow in the knee.
|
|
Or if some fool changes the number of months in the calendar. Then it'll be inaccurate for the new years...or the old.
|
|
|
|
Lousy Smarch weather!
|
Re: Nondeterministic Months
2012-01-05 12:17
•
by
PedanticCurmudgeon
|
inb4 lame comment about how lame linking to xkcd is. |
|
I'm shocked! Shocked, I tell you. Daily WTFs two days in a row!
I was expecting more time to work on my clever comment. Now, all I have is this. |
|
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. |
|
Well, this code is obviously buggy; it didn't work at Kodak.
|
|
One can only assume there is a function somewhere to set the selected year. I'll bet it looks something like this:
function setSelectedYear(year) |
That's, uhhh.... not really applicable here. You fail. |
Re: Nondeterministic Months
2012-01-05 12:22
•
by
some guy
(unregistered)
|
nb4 lame comment on how lame it is to complain about xkcd lamely. |
|
Plausible explanation: it implements an interface designed to support calendars with variable years.
The "selected" year is an object field. In this implementation getMonthCountForSelectedYear() always returns 12. In some other implementation for some other calendar, it makes a decision depending on the year. |
|
function returnTwelve(){
return 12; } |
There, I fixed it. Totally didn't account for twelve changing. Could have been a real pain in the butt. |
|
Code fails to pass standards for following reason: "12 is a magic number". Suggest defining a named literal and assigning it the suitable value, then returning that name from this function.
Edit: curse you MonkeyMojoFish for looking over my shoulder as I type! |
|
Btw, why is twelve such a strange word to say and spell?
|
Re: Nondeterministic Months
2012-01-05 12:34
•
by
the beholder
(unregistered)
|
Gee, why can't people ever be satisfied? function getMonthCountForSelectedYear(string strMonthName)There you go. Happy now? |
|
I can see it being useful for fiscal years - especially when they change when they occur.
Of course, I'm not saying it's a WTF...but it's probably a WTF. |
Agreed, xkcd is 'random' this is static. Even though I admit as soon as I saw the article xkcd was the first thing to come to mind. |
Re: Nondeterministic Months
2012-01-05 12:42
•
by
WTF-land braver
(unregistered)
|
Congratulations sir! Between the parameter that doesn't relate to what the function is supposed to do, the hungarian notation, and the use of string where int would be a more sensible choice you managed to escalate this WTF to a new level. I tip my hat to you now. |
(It's nested function calls all the way down!) |
|
#DEFINE POSSIBLE_MONTHS_IN_THE_YEAR;
function getMonthCountForSelectedYear(aYear) { int year_counter = 0; year_counter = year_counter + 1; for (var i=1; i <= POSSIBLE_MONTHS_IN_THE_YEAR; i++) { year_counter++; } if (year_counter == 12) { return 12; } else { //hmmmm.... } } Who is askimet? |
Try asking the Samoans how many days there were last week! |
|
If you're going with days in a week method what about hours in a day method, or minutes in an hour method.
I'm not a particular fan of constants, because sometimes they are wrong. I've found constants like months = 12 before when it should clearly be 42. |
|
In al mune-base calanders, there is sometime being extra munth aded.
|
Re: Nondeterministic Months
2012-01-05 12:58
•
by
C-Octothorpe
|
An evil, racist AI bent on stopping the dissemination of funny and/or applicable content. |
Re: Nondeterministic Months
2012-01-05 12:59
•
by
Jack
(unregistered)
|
I would guess that the "selected year" is stored in a global variable somewhere (which may be a WTF itself) ... except that the submitter, who presumably knows the system pretty well, was also surprised/amused by the missing parameter. |
|
On years with extra munth, Hindu calander is requiring appropriate secrifise.
|
Re: Nondeterministic Months
2012-01-05 13:03
•
by
You laugh, but...
(unregistered)
|
|
I seriously worked on a group project with someone in CS college who did that.
#define FORTY 40 ... for(i=0; i < FORTY; i++) { ... } I DO like doing something like, #define MONTHS_PER_YEAR 12 because then later when you see code like, for(m=0; m < 12; m++) { do_something(m); } versus for(m=0; m < MONTHS_PER_YEAR; m++) { do_something(m); } ...it is self documenting. "Oh, he's iterating over the months in the year." |
Re: Nondeterministic Months
2012-01-05 13:03
•
by
usitas
(unregistered)
|
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)? |
Re: Nondeterministic Months
2012-01-05 13:04
•
by
Jack
(unregistered)
|
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... |
Re: Nondeterministic Months
2012-01-05 13:08
•
by
EatenByAGrue
(unregistered)
|
10, of course, if you ask the French Republicans. |
|
Many time year is having extra munth. I am on far left at last adhik mas festival.
|
Re: Nondeterministic Months
2012-01-05 13:09
•
by
Jack
(unregistered)
|
They almost universally DO use the Gregorian calendar for anything non-religious, don't they? What do you care how they decide when their holidays will be? |
|
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
|
Re: Nondeterministic Months
2012-01-05 13:17
•
by
EatenByAGrue
(unregistered)
|
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. The One True Calendar, though, is obvious: Start at UTC midnight on what is conventionally called Jan 1, 1970, and count the number of seconds (defined by cesium atoms) since then. |
|
Here's a tip for Jon-Paul regarding the week-length function, although I don't know JavaScript very well. Check if the API has a firstDayOfWeek() and lastDayOfWeek() function, or some equivalent, then subtract the former from the latter, and add one.
daysOfWeek = lastDayOfWeek(n) - firstDayOfWeek(n) + 1 This also elegantly handles cases where there are days between weeks. Those would have incorrectly been counted if you used just firstDayOfWeek(n+1) - firstDayOfweek(n). This algorithm fails, however, for weeks that end before they start. You may want to do a Math.Abs()-equivalent to handle that. Of course, all this assumes roughly equal-length days (give or take a leap second). Should the last day's length approach 0, you may want to leave out the final "+ 1". Hope this helps. In case you need more assistance, I can send you a library with thousands of important numerical constants for date calculations, from ONE through EIGHTYSIXTHOUSANDFOURHUNDRED and many more. |
|
there you go:
function getDayCountForSelectedWeek() { # return 6; return 7; } |
Re: Nondeterministic Months
2012-01-05 13:28
•
by
Anonymous Guy
(unregistered)
|
that was supposed to be a // not a # :) showed that if this guy had written one perhaps he would have prepared the week days go down to 6 :) |
function isDaysCommentFunny (today) {
|
Re: Nondeterministic Months
2012-01-05 13:55
•
by
undefined
(unregistered)
|
I like JavaScript and plain C mixed together. |
|
I asked my wife, and she definitively told me that you will be much happier in life if all your periods have 28 day cycles.
I never argue with my wife because she is always right (she told me so)! |
|
The function should really have a parameter for "planet" in case the code is exported.
|
Re: Nondeterministic Months
2012-01-05 14:04
•
by
Foobar
(unregistered)
|
|
"Twelve" is so strange because it is a word invented by elves. It is a subtle fairy revenge against the English.
Now you know. |
|
Had the code's author used the number 12, Jon-Paul would have thrown the silly programmer "magic number" pet peeve out there. Had the author defined it in a constant, Jon-Paul would have lamented its lack of flexibility. Here he goes, makes it easy to read, and easy to change, and he still gets submitted to this site. Unbelievable.
|
Imet is the guy who wrote the code, I think he is a friend of Nagesh... Go ask him. |
Re: Nondeterministic Months
2012-01-05 14:23
•
by
Pham Nuwen
(unregistered)
|
I'm Programmer-Archaeologist Pham Nuwen, and I approve of this message. |
Re: Nondeterministic Months
2012-01-05 14:26
•
by
J.R.R. Trollkein
(unregistered)
|
This makes perfect sense. Good thing we didn't anger the dwarves. Counting "Ten, Eleven, Twarf" would just be silly. |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |