| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
The real WTF is hardcoded first day of week. In Russia first day is Monday.
|
|
But...why only 13 days? 14 maybe, there might be some code requiring fortnight processing or something. But 13? Bizarre
|
|
ok so theres only two comments on this right now, WTF? don't think i've ever seen it
|
Re: The Long Week
2009-11-11 13:50
•
by
Marvin the Martian
(unregistered)
|
What a heartstoppingly relevant remark to be preserved for eternity: a few minutes after the story was posted, there were only 2 remarks. Who could have guessed? We always thought they'd appear in threes or somesuch. |
Not for long, as your posting gets soon deleted. The real WTF is that there are only 13 entries. And using the same constants twice is a bad idea once the 14-days week had been established this would cause a serious problem. Not mentioning that the days of the week must start from 0. Here is what I would have written: Public Function DayOfTheWeek(iDay As Integer) As String 'Mapping of day number to day-of-the-week string. if(iDay>=14) DayOfTheWeek(iDay%14); if(iDay<0) DayOfTheWeek(14-(abs(iDay)%14)); Select Case iDay Case 0 DayOfTheWeek = STR_SATURDAY Case 1 DayOfTheWeek = STR_SUNDAY Case 2 DayOfTheWeek = STR_MONDAY Case 3 DayOfTheWeek = STR_TUESDAY Case 4 DayOfTheWeek = STR_WEDNESDAY Case 5 DayOfTheWeek = STR_THURSDAY Case 6 DayOfTheWeek = STR_FRIDAY Case 7 DayOfTheWeek = STR_SATURDAY2 Case 8 DayOfTheWeek = STR_SUNDAY2 Case 9 DayOfTheWeek = STR_MONDAY2 Case 10 DayOfTheWeek = STR_TUESDAY2 Case 11 DayOfTheWeek = STR_WEDNESDAY2 Case 12 DayOfTheWeek = STR_THURSDAY2 Case 13 DayOfTheWeek = STR_FRIDAY2 End Select End Function |
|
Friday the 13th!
Which coincidentally also happens this week. |
|
So, ppoplp, instpad of bpllyaching, lpt's hplp Alpx out and submit somp WTF's for him to usp. If wp arp rpading thpm, wp can submit thpm.
(Sorry, pvpry timp I kpy thp lpttpr 'p' I gpt an 'e'.) |
|
This is not that bad. Someone wanted to be able to add a number (less than 7) to the current day of the week and still know what day of the week it would be. Sure, there are other ways to do that, but really it's just a quick hack. I'm surprised this qualifies.
|
|
It looks like it might be useful if you have, say, today's day-in-week number N and you want to show "a week from now" with DayOfTheWeek(N+7), but surely a modulo will be more flexible -- then you can do a fortnight hence as well!
|
You've piqued my curiosity... how did you get that last (real) 'e' in there? Alt + 101? Or were you just faking it? Assuming a non-fake-out, why on earth is your keyboard doing that? |
|
They might be being clever.
If the day offset from the start of the month is a Saturday (day 7) you only need 6 more days to print a calendar by week. Day 13 being Friday. It's an awful way to write the function but it makes sense. Not a total WTF. (PS: I have not thought this through but it the first thing I thought of when I saw it). |
|
I don't see the problem here. This is a perfectly cromulent function. It is a speedier alternative to:
Public Function DayOfTheWeek(iDay As Integer) As String -Harrow. |
Brilliant. I'm sure that's it. I knew I'd seen -- maybe even coded -- a six day offset into the week, but I couldn't remember why! So I made up that unlikely "Tickler scheduler" example. I just wish I could think as fast as you. -Harrow. |
|
The method is obviously misnamed and poorly built. Apparently what was wanted was a day calculator -- as in every 2 weeks on a weekday or some such. As the prevous poster put it, some simple math like modulo could have made it less buggy and virtually limitless. That's what poor math instruction in public schools will do to you
Waitt! But there us an even bigger WTF : why hardcode a culture specific weekday method when most Microsoft frameworks [ guy's using some incarnation of VB for crying out loud] contain excellent culture neutral calendar classes with all kinds of nifty date functions. |
|
Ha! Everybody knows there's "Eight Days a Week."
|
|
For all of you saying this isn't a WTF, consider that it's been deemed such by a guy who thinks Monday was last week.
|
|
Yeah, this is ugly, but it's likely a part of some date-ranging function that takes day of week, adds some-number-mod7 and arrives at a new week day. It can then print the days between them.
The mod is in the wrong place, first. Duplicating code is the next sin. Boneheadedness in the algorithm is the last. |
You, sir, are win. |
|
The real WTF is that while the number of days per year is constantly increasing (by about 68 seconds per century), necessitating adding extra days to the YEAR, the number of days per week is unlikely to undergo any changes anytime soon.
|
Haha, Beatles. I'm a Stones man, myself. Captcha: paratus. Semper Paratus. |
|
I think this is called a "leap week". Didn't they use stuff like that back in the 16th century?
|
amateurs. I once worked on some code that had a PHASE-OF-THE-MOON parameter. It needed to do slightly different processing on a 4 week cycle. |
Re: The Long Week
2009-11-11 15:35
•
by
Ibi-Wan Kentobi
(unregistered)
|
If a fake-out, would he have said "an"? |
Re: The Long Week
2009-11-11 15:35
•
by
Ibi-Wan Kentobi
(unregistered)
|
|
Damn. I meant NON-fake-out.
|
|
Sure, I can think of reasons why I would use a 13-day day calculator. But it's still WTF. Code where you have to think of an explanation for the code is by definition WTF.
|
|
Case 14
DayOfTheWeek = STR_SNORFDAY Actually the 7 day week has probably been around longer than just about any other timekeeping convention, and likely without any interruption. You could go back week by week a few millennia and it'd still work. (Subject to geographical differences -- I don't think the ancient North Americans had a 7 day week, for example.) |
Last week? Try two days ago. I think a little more sleep is still in order. |
Re: The Long Week
2009-11-11 16:09
•
by
My Namp?
(unregistered)
|
Muphry's law strikps again! |
|
Last week if he used the modulo method...
|
|
The real WTF: They forgot Case Else...
|
Re: The Long Week
2009-11-11 16:29
•
by
Yakov Smirnoff
(unregistered)
|
In Soviet Russia we have no WFT's |
|
Very good, but with a slight error. The last statement implies the p's and e's are getting switched.
Unfortunately Rumen forgot to actually do this in the first part of the post. (See ppoplp for instance.) CAPTCHA: saluto And saluto to you! |
Gory details: http://en.wikipedia.org/wiki/Seven-day_week |
SarahE: copy + paste. This would also explain the "an"... but there's still the problem of switched "p" and "e". The statement should've been -- maybe someone missed their coffee for the day? |
In Soviet Russia, WTF code executes you! |
|
It actually makes sense. If you use any number modulus 7, you end up with a result between -6 and 6. If you then add 7 to this result, you start at 1 and end with 13. These numbers would be matching the exact outcome of this function.
|
Re: The Long Week
2009-11-11 17:13
•
by
W.A. ten Brink
(unregistered)
|
|
The WTF is that you disagree with using 13 numbers... Do this:
iDay = (iRandomDay%7)+7 When -RandomDay is negative, you would get a negative value with the % but by adding 7, all days end in the range between 1 and 13... It actually makes sense, especially if you'd allow negative dates... |
|
hm, wouldn't it have been better to use a LinkedList in case the weekdays change more often (and to make it easier in case the days switch places)? then you wouldn't even have to recompile/restart the app so often ;)
na, seriously: what really _is_ the best solution for something like this? my guess would be an array with the weekday names and an offset-variable eg. for countries where weeks don't start mondays (aka. USA). so you can do sthg like this in java (which even supports weeks with different than 7 days): String getDayName(int day) { return dayname[(day + offset) % dayname.length]; } CAPTCHA: dignissim |
|
The problem is that the coder was only a demi-god. As such it was only on the 14th day he/she rested. Only the big fella gets the managerial privilege of having a day off EVERY week....
|
|
TRWTF is that Apple is now reinventing the week, and TRRWTF is that they're calling it the iDay instead of the iWeek. Typical.
|
Nope. Every time DayOfTheWeek is called, it's called like this:
|
|
The submitter should have more humility and faith in other human beings. There's obviously something intentional about the 13 days. At a minimum this sequence can encode any week that begins on any particular day:
Sunday through Saturday Monday through Sunday ... Saturday through Friday |
|
Totally done it. TI 83+ graphing calculator in highschool (woah, 12 years ago now?). I built a simple schedule program to track homework and activities. Mine was a bit different in that the DAYS_OF_WEEK were stored in a 13 element array, a quick look at array(current+change) would result in the correct day no matter what. This method WAS faster than mod.
TiBasic, bitches, it works. |
|
Case 14
DayOfTheWeek = FILE_NOT_FOUND |
13 days of the week should be enough for anyone. |
Rumen's post contains two 'e's.... |
Yup, much better now. |
|
Hahaha,
Alex, how are the drinks at the convention? Sandor |
Same story here: the week-end is the end of the week. |
It reminds me of a prank I've read somewhere recently (a webcomic?): you detach two keys from the keyboard of a coworker (who type looking at the chars) and reattach them switched; then wait. Some keyboards (IBM for instance) have the chars over "key-covers" you can easily pop out; I think it was done for make localization costs cheap. CYA |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |