- 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
I found it more confusing that I can't determine which field is month and which is day from a glance than the WTF itself, which is immediately obvious.
Admin
$fristChar was missing - that's the biggest problem.
Admin
The real WTF is putting the least significant digits between more significant digits.
Admin
trwtf is not using ISO 8601 and using yyyymmdd or similar. I've seen enough confusion about whether 7/1 means 1st July or 7th Jan
Addendum 2019-11-19 06:57: (Remy please note)
Admin
I hate to say this but PHP is the least of his problems.
Admin
The funniest bit is where it carefully checks that the second character is a forward slash, and if not, then it carefully checks whether the second character is not a foward slash. Just in case the Law of the Excluded Middle does not hold in this context.
Suppose "date" may have changed in between, maybe.
Admin
Even if $date did somehow manage to change (considering it is a parameter passed by value...), $secondChar wouldn't.
Admin
The real wtf is complaining about mm/dd/yyyy when you use dd/mm/yyyy on a programming website where yyyy-mm-dd is the only acceptable answer.
Admin
I saw something similar to this once. There was an external component that our program was interacting with. That program had a non-standard version string format that included letters and variable width fields. Instead of using a regular expression to parse it, the previous developer had decided to create a function that did character extraction to test whether the version string was equal to or later than a particular version of interest.
Then they had to create another similar function for a different version of interest.
Then another.
And another.
When I got there, there were about seven or eight of these 'isVersionXXOrLater' functions. All doing character extraction and testing to determine the version attributes. Sometimes doing it wrong.
Admin
He's a constructivist.
Admin
He is indeed. That was the term I was hunting for. Thnx. Brouwer would be proud.
Admin
I've seen code that uses a gigantic switch statement to do this for months and then days of the month. Splits on / (wrooong) and then switch (monthStr) { case "1": case "2": ... case "9": monthStr = "0" + monthStr; break; case "10": case "11": ... case "31": monthStr = monthStr; break; }. The best I can say is that at least they combined the cases instead of replicating "0" + for every one.
Admin
This is the kind of problem you end up with when programmers have trouble getting a date.
Admin
Why do you think I use dd/mm/yyyy ?
Admin
TRWTF: "but since there had just been a massive refactoring project, nobody want to make any code changes which weren’t new features."
Refactoring should be part of DAILY work not a "massive project".... Remember Red, Green, REFACTOR.
Admin
This code also has an "off-label" use to return the month abbreviation. For example, convertSingleDigitMonthOrDayToTwoDigitMonthOrDay("January 1st") returns "Jan". It's a feature and it might be used that way in the code, so you can't change it.
This function will also return the first 6 characters of a random string, as long as the 3rd char is the only '/'.
Admin
Funniest part is the code is wrong...
Admin
Gotta grudgingly give some points to the function's name, that's a rare occurrence in that kind of mess.
Admin
No I don't.
No I don't.