diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntry.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntry.cs index 61466a3988766c..0f9c79247dc715 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntry.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntry.cs @@ -247,7 +247,7 @@ public DateTime TimeGenerated { get { - return beginningOfTime.AddSeconds(IntFrom(dataBuf, bufOffset + FieldOffsets.TIMEGENERATED)).ToLocalTime(); + return DateTime.UnixEpoch.AddSeconds(IntFrom(dataBuf, bufOffset + FieldOffsets.TIMEGENERATED)).ToLocalTime(); } } @@ -258,7 +258,7 @@ public DateTime TimeWritten { get { - return beginningOfTime.AddSeconds(IntFrom(dataBuf, bufOffset + FieldOffsets.TIMEWRITTEN)).ToLocalTime(); + return DateTime.UnixEpoch.AddSeconds(IntFrom(dataBuf, bufOffset + FieldOffsets.TIMEWRITTEN)).ToLocalTime(); } } @@ -475,7 +475,5 @@ private static class FieldOffsets internal const int DATAOFFSET = 52; internal const int RAWDATA = 56; } - - private static readonly DateTime beginningOfTime = new DateTime(1970, 1, 1, 0, 0, 0); } } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs index e52996a4a9adad..e7bc10fda01a4a 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs @@ -119,7 +119,7 @@ public static Func, BlobContentId> GetTimeBasedProvider() // In the PE File Header this is a "Time/Date Stamp" whose description is "Time and date // the file was created in seconds since January 1st 1970 00:00:00 or 0" // However, when we want to make it deterministic we fill it in (later) with bits from the hash of the full PE file. - uint timestamp = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + uint timestamp = (uint)DateTimeOffset.UtcNow.ToUnixTimeSeconds(); return content => new BlobContentId(Guid.NewGuid(), timestamp); }