DateTime.ToString method throws an exception


(takepoi) #1

Also, I would like an overload that allows you to specify a format like .NET.

(takepoi) #2

First, If you specify ticks less than 1 day in the constructor of DateTime,
there is a bug that the Day property will be 0.

In addition, we use the GetDateFormatEx function inside DateTime,
This function will cause an error if the number of years is less than 1601.

I wrote the code “new DateTime(DateTime.Now.Ticks - startTicks)” to measure time,
and processing was completed in a few minute.

As a result, date of new DateTime instance became “January 0 0001” and an error occurred with the GetDateFormatEx function.

The .NET Framework DateTime.ToString() has been formatted correctly.
Can I take countermeasures?

(Carlo Kok) #3

Easiest is just to grab the source and fix it.

Alternatively wait for us to do it