- 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
My initial guess was that it's a shitty way of making a copy, but DateTime is a struct and thus always copied on assignment. Maybe they are trying to discard sub-second precision? Or just don't understand structs?
Edit Admin
You left out "or just don't understand"...
Admin
Grey cells? What, is this prison?
Admin
So ... am I missing something, or could they just have checked member.PubDate.HasValue instead of parsing?
Edit Admin
Don't forget that they forgot the culture! So, the ToString call on the initial DateTime will be formatted according to the current culture, which could be day/month/year. However, the parse is given an exact format string, so the culture (null implies current IIRC) is mostly disregarded in favor of the format string they specified.
As @anExactDate theorized, they're either incompetent or were trying to discard sub-second precision. My money is on the former.
Admin
"Which sure, this is almost certainly server-side code running on a single server with a well known locale configured. So this probably won't ever blow up on them, but it's 100% the kind of thing everyone thinks is fine until the day it's not."
That's really fun to find out when you're in some kind of emergency. Your physical server dies so you push your backup to a VM to stay online. A day later all your new orders show up in the wrong month. Oh, your local server had a proper locale setting put in by your admin in 2007 and the VMs are all clones of a default en-US image? Well, better get on with manually adjusting all those dd-mm to mm-dd.
Edit Admin
It's likely a Poirot reference. :)
Edit Admin
"well known locale configured" Ha. Only US coders will use that excuse.
Edit Admin
Yeah, looks to me like is was written by a Java developer. I have encountered a lot of times where deep copies are wrongfully made like this (there's better ways to do it) and when it is value types, it was always a Java developer who made it through the HR process because those people often think that .net and Java is the same. To be frank, it's not their fault, to me woman and man are the same too but HR people would completely disagree.
Admin
Maybe I'm overlooking something, but could it be that member.PubDate is NOT of type datetime at all, yet has a well known tasting function?
Admin
Re. Easy Reader Version, cuneiform is text too.
Edit Admin
TRWTF is the ad being commented out by the easy reader version