Why is this an issue?
With .NET Core the
UnixEpoch field was introduced to
DateTimeOffset types. Using this field
clearly states that the intention is to use the beginning of the Unix epoch.
What is the potential impact?
You should not use the
DateTimeOffset constructors to set the time to the 1st of January 1970 to represent
the beginning of the Unix epoch. Not everyone is familiar with what this particular date is representing and it can be misleading.
How to fix it
To fix this issue, use the
UnixEpoch field of
DateTimeOffset instead of the constructor.
Noncompliant code example
var epochTime = new DateTime(1970, 1, 1);
var epochTime = DateTime.UnixEpoch;