Date format island vs toffee

Hi,

I have this

      var newDate := new DateTime(DateTime.UtcNow.Ticks);
      Log($'{newDate}');

in 2 mac console apps, one is darwin the other is toffee.

Toffee gives this

2022-07-06 00:05:40 +0000

Island gives

06/07/2022 00:07:08

Should they use the same formatting ?

Cheers,
John

Good question. I’d say no (not necesarily). Right now, the parameter-less ToString() (which gets hit here, when passing objects to String.Format) calls the ToString (equivalent) of the underlying native date type, and thinking about it, I believe this to be the desired behavior.

Dates are a complex thing, and calling ToString() without a format for anything but debugging purposes seems like a really bad idea. To show dates to the end-user of your application, to save them to text files, or to in any other way, shape, or form get a consistent and reliable string representation for a date, you should call one of the ToString() overloads that take an explicit format, or cal the other To*String convenience methods, such as ToShortPrettyDateString, etc. (those should all behave consistently, and if they don’t, please let me know).

PS, missed that, but I assume you are only referring to the difference formatting, and that the actual date value was correct and you did run these two, some 88 seconds apart, yes?

Yes just the formatting

1 Like