From 117176513829c8bbcf16fc70d841c9811b281872 Mon Sep 17 00:00:00 2001 From: Jason Gilbertson Date: Mon, 5 Apr 2021 12:45:11 -0400 Subject: [PATCH] TimeUtil.cs add public static property DateTimeKind defaulted to current value DateTimeKind.Local to allow parsing of .blg from different timezone (#65) * Update Build.cmd * Update Build.cmd * Update Build.cmd * TimeUtil.cs add static DateTimeKind option defaulted to DateTimeKind.Local. This allows the parsing of a performance counter file created in a different timezone. For performance counter files in azure (utc), setting DateTimeKind.Utc. --- Source/Tx.Windows/TimeUtil.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Tx.Windows/TimeUtil.cs b/Source/Tx.Windows/TimeUtil.cs index 2ebe4ed..cbbaaf4 100644 --- a/Source/Tx.Windows/TimeUtil.cs +++ b/Source/Tx.Windows/TimeUtil.cs @@ -4,10 +4,11 @@ using System; namespace Tx.Windows { - // We implemented this in Tx, because the default .Net implementation was too slow - // We should do experiment if we still need it public sealed class TimeUtil { + // DateTimeKind option needed for overriding DateTimeKind if parsing + // performance counter blg from different timezone than creation time zone + public static DateTimeKind DateTimeKind {get; set;} = DateTimeKind.Local; private const Int64 TicksPerMillisecond = 10000; private const Int64 TicksPerSecond = TicksPerMillisecond * 1000; private const Int64 TicksPerMinute = TicksPerSecond * 60; @@ -35,7 +36,7 @@ namespace Tx.Windows public static DateTime FromFileTime(Int64 fileTime) { - return new DateTime(FileTimeOffset + fileTime, DateTimeKind.Local); + return new DateTime(FileTimeOffset + fileTime, DateTimeKind); } } } \ No newline at end of file