• anExactDate (unregistered)

    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?

  • (nodebb) in reply to anExactDate

    You left out "or just don't understand"...

  • some guy (unregistered)

    Grey cells? What, is this prison?

  • Marvin (unregistered)

    So ... am I missing something, or could they just have checked member.PubDate.HasValue instead of parsing?

  • (nodebb)

    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.

  • guest (unregistered)

    "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.

  • (nodebb) in reply to some guy

    It's likely a Poirot reference. :)

  • (nodebb)

    "well known locale configured" Ha. Only US coders will use that excuse.

  • (nodebb) in reply to anExactDate

    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.

  • JohanE (unregistered)

    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?

  • MRAB (unregistered)

    Re. Easy Reader Version, cuneiform is text too.

  • Kleyguerth (github)

    TRWTF is the ad being commented out by the easy reader version

  • Loren Pechtel (unregistered)

    This actually does something--zaps anything that isn't a correctly formatted date. Whether that is a desirable action or not depends on the situation...

Leave a comment on “Exactly a Date”

Log In or post as a guest

Replying to comment #680095:

« Return to Article