• some guy (unregistered)

    frist, let's do a calculation: $CURRENT_YEAR - 999 = 1025. If that counts as "within the last 2,000 years or so", why doesn't Remy loan me $ 2,000 and I pay him $ 1,025 back?

  • Industrial Automation Engineer (unregistered)

    to add zero's in front of a number, use: right$("0" + day$,2)

    that's how I did it 40 years ago, when GW-Basic was still cutting edge technology. I had hoped we had come some way since then, but apparently not.

  • DQ (unregistered)
    which will be 4 digits anytime within the last 2,000 years or so
    You mean the last 1,000 years, right?
  • L (unregistered) in reply to DQ

    only if you are using the Gregorian or Julian calendar

  • (nodebb)

    @DQ: Evidently dates are hard. Who knew?

  • (nodebb) in reply to WTFGuy

    @DQ: Evidently dates are hard. Who knew?

    In my experience, they aren't close to that easy.

  • Sauron (unregistered)

    a "CodeSOD" is a "Code Sample of the Day"

    The "S" in CodeSOD means "Snippet", not "Sample", according to the description at the top of this page: https://thedailywtf.com/series/code-sod

    lol

  • Pabz (unregistered)

    I thought that a CodeSOD was a "Code Snippet of The Day" as mentioned at https://thedailywtf.com/series/code-sod

  • Pabz (unregistered)

    @Sauron You beat me to it!

  • (nodebb)

    I tend to think of CodeSOD as meaning code that should sod off, in British slang.

  • kythyria (unregistered)

    The worst bit is, the way you format dates is to pass the format string to ToString. The overload is RIGHT THERE and likely shown in the IDE's popup.

  • Hasseman (unregistered)

    And how about localised date strings ... yyyyMMdd, MMddyyyy, ddMMyyyy and other variants

  • (nodebb)

    So, uh, "86" on StringOfToday()?

    Any respectable restaurant would take that off the menu, and fast!

  • Duston (unregistered)

    Everyone knows the "right" way to do this is with an XML transform. Of course!

  • (nodebb) in reply to adamantoise

    I tend to think of CodeSOD as meaning code that should sod off, in British slang.

    I also thought this, TBH.

  • DQ (unregistered) in reply to L

    Well, Remy was using the Gregorian calendar so I kept in sync.

  • Tinkle (unregistered)

    The original code is by an amateur.

    Everyone knows that the correct way to WTF a date to string function is to use ToString and then substring to pull out the required bits...

  • Erwin (unregistered)

    Buffer overflows give me heartburn.

Leave a comment on “String Du Jour”

Log In or post as a guest

Replying to comment #:

« Return to Article