- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Don't forget the 2 global variables in PopulateDates. O_o
A straight up search and replace is going to be a problem. Better to rewrite PopulateDates to use ToShortDateString instead.
Admin
I'm pretty sure that the auto industry has it's own annual calendar, which is what all of the date arithmetic is about.
Admin
The real WTF is VB.
Admin
I've worked with custom calendars. Not a one has any insane logic like this.
Admin
The real WTF is VBScript!
(VB is fine)
Admin
VB.Net is fine. VB is... special.
Admin
Admin
What happens to the text boxes that are now not populated because he's replaced the call to the method that would populate them...
Admin
If you're rolling your own date logic, chances are better than 99% you're Doing It Wrong.
Of course, if the human system for reckoning time is so thoroughly hosed that 99 out of 100 programmers can't implement it, is there any chance some of the blame might lie with the human system for reckoning time?
Admin
Human are far too lazy to try look up how it works to implement it correctly in the first place.
Most 'implementations' I've seen are based on bad assumptions and a complete disregard to Timezones,Formats,Cultures, etc...
Admin
Absolutely not. The ability to handle the really-quite-straightforward technique for reckoning time according to the Gregorian calendar is a pons asinorum in the understanding of the universe. And if there are computer programmers who do not have the basic intelligence to be able to understand how a calendar works, they have absolutely no business being in the industry.
What's the current socio-political position as regards eugenics and euthanasia for the terminally thick?
Admin
Windows system date also cause many issue due to cultural impositions and varied date formats in all parts of universe.
Admin
This code would work fine with a lunar calendar.
Just need to use InvariantCulture. For some reason which I don't understand, that uses US style rather than ISO 8601.Admin
There's a couple of bugs in January, but I don't really see the big WTF. Seems like they just need an approximate last week.
Admin
My employer uses some oddball logic to calculate it's financial calendar. (Though this looks less "insane" and more "incomplete" to me.)
The complicated logic is why we almost never actually store anything in the financial calendar's format. We just convert it when we need it instead -- usually just for reports.
Admin
Somebody help me out here... WTF was the programmer doing?
Here are a selection of dates run through this bizarre algorithm: Good WTF 12/05/1999: 10/25/1999 01/18/2000: 0/11/2000 01/23/2000: 0/16/2000 02/12/2000: 1/5/2000 03/20/2000: 2/13/2000 12/15/2000: 11/8/2000 01/19/2001: 0/12/2001 02/06/2001: 0/26/2000 02/15/2001: 1/8/2001 02/28/2001: 1/21/2001 04/17/2001: 3/10/2001 06/10/2001: 5/3/2001 09/06/2001: 7/26/2001 10/24/2001: 9/17/2001 12/22/2001: 11/15/2001 01/21/2002: 0/14/2002 02/20/2002: 1/13/2002 03/25/2002: 2/18/2002 10/24/2002: 9/17/2002 12/19/2002: 11/12/2002 01/12/2003: 0/5/2003 02/18/2003: 1/11/2003 03/05/2003: 1/25/2003 03/28/2003: 2/21/2003 04/11/2003: 3/4/2003 05/03/2003: 3/23/2003 09/29/2003: 8/22/2003 10/11/2003: 9/4/2003 11/23/2003: 10/16/2003 11/23/2003: 10/16/2003 12/18/2003: 11/11/2003 02/01/2004: 0/21/2003 03/24/2004: 2/17/2004 03/24/2004: 2/17/2004 04/23/2004: 3/16/2004 08/27/2005: 7/20/2005 10/02/2005: 8/22/2005 11/30/2005: 10/23/2005 12/04/2005: 10/24/2005 12/09/2005: 11/2/2005 12/22/2005: 11/15/2005 01/26/2006: 0/19/2006 02/25/2006: 1/18/2006 04/22/2006: 3/15/2006 04/12/2007: 3/5/2007 04/12/2007: 3/5/2007 06/03/2007: 4/23/2007 10/13/2007: 9/6/2007 11/19/2007: 10/12/2007 12/27/2007: 11/20/2007 01/04/2008: -1/24/2008 02/12/2008: 1/5/2008 02/19/2008: 1/12/2008
My favourite has to be -1/24/2008.
It is pretty obvious what TRWTF is this time... m/d/y :-p
Edit: Let me qualify I used Java Calendar to get the year, month, and day of month, which I assumed was the same as VB's, and may be an invalid assumption.
Admin
Of course, the real WTF is that both Jeff and Tabitha are working at 7:15. Which 7:15 it is, they don't say (another failure of the US way; the civilised world uses the 24-hour clock). Either this is 7:15 pm, which means that they're both staying late, or they start really early in the morning.
Admin
Aside from the already mentioned 'month 0' WTF and the obvious but strangely not explicitely commented yet 'treat all months as 28 days' lunar calendar approach WTF, there are WTFs in the article conclusion as well. Someone already mentioned 'replaced a sub with a function', but why that function was about date formatting and not date arithmetics (i.e. DateAdd) is a bigger WTF.
The real WTF of course are the parents that could not spell Tabitha properly. (edit: oh wait, it is spelled correctly in the first instance in the article, but not in the rest... so whose WTF is it really, the article author, or the poor girl's parents?)
Admin
"pm" is a redundant information.
No real programer starts before 9:00 am. And start means here "first coffee". So 7:15am is something which will never happen. The 'pm' can be dropped.
Admin
I'm with Tabitha. The code is bug-free. It fills in two text boxes on the form with today for the end date, and something over a week ago for the begin date. By doing a global substitution instead of simplifying the routine, Jeff broke the build. And, he should have been looking for the problem in the logging section, not creating new ones in the reporting section.
Admin
Edit: and aside from the month parts, it seems to me you have messed up the resulting day parts for inputs in the first seven days of a month.
Admin
While I agree that it probably constitutes a WTF, some financial calendars consist of 13 28-day "periods" in a year. Except for every 5-7 years there is a period that is 5 weeks instead of four. It was more common in the 50's and prior than it is now (according to my parents anyway... I wouldn't know).
Admin
I can add that I unfortunately work for a company who still uses this format.
Admin
Surely the "human system for reckoning time" is based on the Earth's rotation and its orbit around the Sun. Maybe the blame lies with God.
Admin
And yet... There they are.
The real wtf is the arse backwards American date format. Amirite?
Admin
Jeff was lucky. Humor in our offices is only allowed from 4:50pm to 5:00pm. Any sooner than that and you risk being written up for being disruptive and 'not a team player'. Attempts at making humor must be announced via the holding of an orange neon card as the humor is being made. Failure to use the orange neon card will also result in a write up. Attempts at making an 'off color humor' will not be tolerated, but some of us hear stories about how upper management is allowed to do so, and that it requires a UV reactive black card. We're debating going in and acquiring one of these cards as apparently a coworker has an awesome joke about a duck, a midget, a dragon, a radish and the CEO. I look forward to to the day we can acquire one of those black cards.
Admin
AM/PM forever, you foreign third-world heretics!
One day you will learn to do things the same as the great US of A!
Admin
I wonder if Jeff gets ta-bath-a with her?
Admin
Admin
I'm guessing that Jeff isn't the hero of this story, he's the butt of the joke, yes?
a) he doesn't seem to fix the original problem b) he messes with code he doesn't seem to understand, despite his supervisor saying it isn't required c) he introduces a new bug with his global search/replace d) he does all this because he doesn't like the way date to string conversions have been done
Admin
Can we maybe keep the "quirky" characters and clumsy storytelling out of CodeSOD?
Admin
Amazing things about this story:
Managing to run VB.NET inside a vbs file (vbs did not have DateTime - thats a .NET object)
Managing to update a textbox from a vbs file
Author/Editor: If you're going to anonymize, at least get a clue!
Admin
Should have named it "MangleDates()"...
Admin
So he works with two ladies with similar sounding names who are both his boss and both use understated and sarcastic humor? I'm confused.
(Tabitha or Tabatha?)
nimis: He sailed on the U.S.S. Nimis.
Admin
I call BS. What version of VBS lets you A) Specify types (Everything is/was a Variant), and B) Has a ToShortDateString() method?
This is VB.NET code. If you're going to anonymize, then stay consistent. If the sales logger is VBS, then it wouldn't have VB.NET code, unless I missed something.
Also, the supervisor's nonchalant response indicates that she probably wrote it.
Admin
Admin
By the way, we're "civilized."
Admin
The code has two problems.
The first is definitely a problem as the resulting date is invalid.
The second could be a problem, this result would not appear to be intentional. (my guess is that this has been noticed by the car salespeople for years as it amounts to double counting sales made between the 28th and 31st of the month).
The developer has a different issue, he expects his boss to instantly see the problem in the code, and points out that he is not sure if she does. He should be telling his boss I found these two problems, and I am going to make the code behave like this. Only the first problem was reported, not the second.
Admin
The problem is that the rotation around the sun doesn't occur at an exact number of earth's rotations. Which means that every year occurs within 365.xx days. That little xx is what causes our years to have extra days in them.
We try to fit in those extra days by blowing up that fraction until we have how many days per set of years. But the fraction is so precise that we can't use filler days with any degree of sanity. Plus, we don't have a precise calculation for that fraction, so we find out every now and then we're off by an hour or so.
Because we like base 10 so much, instead of adding days per x years. We add 1 day per 4 years except every 100 years except every 1000 years. So 1700, 1800, 1900 not a leap year, but 2000 is.
This is all because we prefer our years to land on solar dates.
We could of course switch back to a lunar calendar.
Admin
Aw man I was going to call that TRWTF. Captch nulla; you getta nulla youa throwa ana exception.
Admin
What about cases where we use the Mayan Calendar -oh wait it's too late for that.
Admin
Admin
And it is one leap year per four years, except every hundred years, except every 400 years. (Technically, every century year before 1600 was a leap year because the Gregorian calendar that introduced the except-100-exceptsquared-400 rule wasn't invented until after 1500.) (/hat)
Admin
The reason 13x28 day months are used in accounting (not just finance) is to make year-to-year results comparable. Without months being even modulo weeks there would be some years with a few percent more business days in them than others, leading to random variations in year-to-year (and month to month) results, which noise would swamp the signal of how the business is doing. It's GAAP. Before laughing at a non-techy, learn a bit about why it's done that way, and then see if you can figure out a better way. Harvard Business School would love to hear from you.
Admin
Admin
"Find All References"
VB .NET has many WTFs. See: IIF
Us Americans are smart enough to read the "resigned to working after 5 PM" part.
Array indices start at zero in VB .NET
Wrong, date formatting is for the UX guys. :)
Admin
You mean yyyymmdd. The hyphens are redundant.
As are the periods. /joke
Admin
Why I spent so much time on this, I'll never know.
Anyway, here are the results run through VBA Excel:
And here's the modified for VBA code for your review
Admin
Note that only 1/4/2008 gave any problems
Admin
WTF? Why does a date format have to end with a period?
Signed, Mr. You_Should_Have_Used_Quotation_Marks .