BUG: The added or subtracted value results in an un-representable DateTime

We ran into an issue where the FromUnixTimeMs() is throwing an error when executing the following code:

(-125857756800000).FromUnixTimeMs()

I would have expected it to return this value:
image

If I chop off the milliseconds, then the code works, but I shouldn’t have to do this:

(-125857756800).FromUnixTimeMs()

As the name suggests FromUnixTimeMs() expects the Unix time in milliseconds.

This results in a DateTime that is -1456687 days or 4000 years in the past which is unrepresentable by a .NET DateTime and why this fails:

var fromMilliseconds = TimeSpan.FromMilliseconds(-125857756800000);
return UnixEpochDateTimeUtc + fromMilliseconds;

We don’t have an extension method to convert from Unix Micro Seconds, you’d need to /1000 to calculate milli seconds and use FromUnixTimeMs() or wrap it in your own FromUnixTimeMicroSeconds() extension method that does it.

Ah that makes sense. I didn’t even realize it was “microseconds” even though it says it in the epochconverter.com I just assumed it was “milliseconds”, as that’s what we’ve standardized on.