• MRAB (unregistered)

    Why is the first function called 'GetTimeStamp'? It's not getting the timestamp, it's formatting a timestamp that its caller is passing in.

    Oh, and frist!

  • (nodebb)

    99 milliseconds should be enough for anyone.

  • (nodebb)

    Copy pasta is the favorite food of bad programmers everywhere.

  • Richard Brantley (unregistered)

    What amazes me about this kind of thing, so constantly, is that .NET comes with the most “batteries included” functions for so many things, date/time handing being exceptionally rich. But a lot of junior devs don’t bother to learn the framework, or maybe spend a minute in a search engine asking “has someone else in the history of programming ever solved this problem before?”

  • Tinkle (unregistered)

    Hmm, a one-liner that does the same.

    private string FileTimeStamp(DateTime param) { return param.Year.ToString() + "-" + ((param.Month < 10) ? "0" : "") + param.Month.ToString() + "-" + ((param.Day < 10) ? "0" : "") + param.Day.ToString() + " " + ((param.Hour < 10) ? "0" : "") + param.Hour.ToString() + ":" + ((param.Minute < 10) ? "0" : "") + param.Minute.ToString() + ":" + ((param.Second < 10) ? "0" : "") + param.Second.ToString() + "." + ((param.Millisecond < 10) ? "0" : "") + param.Millisecond.ToString(); }

    Gotta be right?

  • Joe (unregistered) in reply to Richard Brantley

    Maybe this code was ported from a language that doesn't have good formatting built-in like .NET, and the ones doing the porting wanted to be as hands-off as possible, just a theory. Think about it - if you need the new system to behave exactly as the old system, you're gonna need to keep that milliseconds bug in there :-)

  • (nodebb)

    string retDate = param.Year.ToString() + "-";

    TRWTF is they didn't use var there, right?

  • (nodebb) in reply to Dragnslcr

    That attitude will not get you any second dates (of the woman kind)

  • t (unregistered) in reply to Richard Brantley
    Comment held for moderation.
  • y2k16 (unregistered)

    This is clearly auto-generated code which was perfectly concise in its original form. I'll wager milliseconds were a later addition and were simply tacked onto the end of a list somewhere, in the full knowledge that any inconsistent formatting will never get picked up in testing and whatever unit tests currently exist continued to pass. The generated strings are unique and that's good enough. If a system level bug occurs, then the blame is shared with whatever code expects milliseconds with up to four leading zeros. If an inode falls in the forest and nobody reads it, does it really exist? No.

    That or it's LLM generated, in which case the prompter is clearly a 1000x high flyer who will already be a favourite before the consequences can come back to bite them

  • Tim (unregistered)

    Actually I wouldn't have been at all surprised if the second version had the millisecond bug fixed.

    That would be a typical maintenance scenario of making sure you don't "break" any existing use cases and fixing only the one you need.

  • (nodebb)

    It's a shame the second function wasn't called GetTimeStampNew.

  • VB Guy (unregistered) in reply to Tinkle
    Comment held for moderation.
  • xorium (unregistered)
    Comment held for moderation.
  • Graculus (unregistered) in reply to Tinkle
    Comment held for moderation.

Leave a comment on “A Second Date”

Log In or post as a guest

Replying to comment #681383:

« Return to Article