How About Next Month
by in CodeSOD on 2024-03-18Dave's codebase used to have this function in it:
public DateTime GetBeginDate(DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month, 01).AddMonths(1);
}
Dave's codebase used to have this function in it:
public DateTime GetBeginDate(DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month, 01).AddMonths(1);
}
Date problems continue again this week as usual, both sublime (Goodreads!) and mundane (a little light time travel). If you want to be frist poster today, you're going to really need that time machine.
Early Bird Dave crowed "Think you're hot for posting the first comment? I posted the zeroth reply to this comment!" You got the worm, Dave.
Rui recently pulled an all-nighter on a new contract. The underlying system is… complicated. There's a PHP front end, which also talks directly to the database, as well as a Java backend, which also talks to point-of-sale terminals. The high-level architecture is a bit of a mess.
The actual code architecture is also a mess.
Branon's boss, Steve, came storming into his cube. From the look of panic on his face, it was clear that this was a full hair-on-fire emergency.
"Did we change anything this weekend?"
Donald was cutting a swathe through a jungle of old Java code, when he found this:
protected void waitForEnd(float time) {
// do nothing
}
FreeBSDGuy sends us a VB .Net snippet, which layers on a series of mistakes:
If (gLang = "en") Then
If (item.Text.Equals("Original")) Then
item.Enabled = False
End If
ElseIf (gLang = "fr") Then
If (item.Text.Equals("Originale")) Then
item.Enabled = False
End If
Else
If (item.Text.Equals("Original")) Then
item.Enabled = False
End If
End If
Inability to properly program dates continued to afflict various websites last week, even though the leap day itself had passed. Maybe we need a new programming language in which it's impossible to forget about timezones, leap years, or Thursday.
Timeless Thomas subtweeted "I'm sure there's a great date-related WTF story behind this tweet" Gosh, I can't imagine what error this could be referring to.
Today, John sends us a confession. This is his code, which was built to handle ISO 8583 messages. As we'll see from some later comments, John knows this is bad.
The ISO 8583 format is used mostly in financial transaction processing, frequently to talk to ATMs, but is likely to show up somewhere in any transaction you do that isn't pure cash.