From 395abe190b9d30a3b258b646cf405434db578cf3 Mon Sep 17 00:00:00 2001 From: Nikolay Zdravkov Date: Sat, 25 Apr 2026 01:25:01 +0300 Subject: [PATCH 1/3] refactor: use DateTimeOffset.ToUnixTimeSeconds in BlobContentId --- .../src/System/Reflection/Metadata/BlobContentId.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } From 7d0d62bb14068806e0042cb4e432cc1983bf22cc Mon Sep 17 00:00:00 2001 From: Nikolay Zdravkov Date: Sat, 25 Apr 2026 01:25:02 +0300 Subject: [PATCH 2/3] refactor: use DateTime.UnixEpoch in EventLogEntry --- .../src/System/Diagnostics/EventLogEntry.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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..db2eb3a33f3e3c 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(); } } @@ -476,6 +476,5 @@ private static class FieldOffsets internal const int RAWDATA = 56; } - private static readonly DateTime beginningOfTime = new DateTime(1970, 1, 1, 0, 0, 0); } } From 5739c67c0db850c910dd38aa166d486d750615db Mon Sep 17 00:00:00 2001 From: Miha Zupan Date: Sat, 25 Apr 2026 01:13:20 +0200 Subject: [PATCH 3/3] Remove extra blank line --- .../src/System/Diagnostics/EventLogEntry.cs | 1 - 1 file changed, 1 deletion(-) 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 db2eb3a33f3e3c..0f9c79247dc715 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntry.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntry.cs @@ -475,6 +475,5 @@ private static class FieldOffsets internal const int DATAOFFSET = 52; internal const int RAWDATA = 56; } - } }