From 5f73ce568bf2c2225444ed4e25435fa217a9f028 Mon Sep 17 00:00:00 2001 From: Alex Maitland Date: Tue, 6 Sep 2022 14:20:53 +1000 Subject: [PATCH] Core - Migrate from CefTime to CefBaseTime (CefNavigationEntry) - Add new method to convert from CefBaseTime to DateTime Issue #4234 --- CefSharp.Core.Runtime/Internals/TypeConversion.h | 7 +------ CefSharp/Internals/CefTimeUtils.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CefSharp.Core.Runtime/Internals/TypeConversion.h b/CefSharp.Core.Runtime/Internals/TypeConversion.h index 78e1d4c78..723641952 100644 --- a/CefSharp.Core.Runtime/Internals/TypeConversion.h +++ b/CefSharp.Core.Runtime/Internals/TypeConversion.h @@ -300,12 +300,7 @@ namespace CefSharp return gcnew NavigationEntry(current, DateTime::MinValue, nullptr, -1, nullptr, nullptr, (TransitionType)-1, nullptr, false, false, sslStatus); } - //TODO: Issue #4234 - auto baseTime = entry->GetCompletionTime(); - CefTime time; - cef_time_from_basetime(baseTime, &time); - - DateTime completionTime = CefTimeUtils::ConvertCefTimeToDateTime(time.GetDoubleT()); + DateTime completionTime = CefTimeUtils::FromBaseTimeToDateTime(entry->GetCompletionTime().val); auto ssl = entry->GetSSLStatus(); X509Certificate2^ sslCertificate; diff --git a/CefSharp/Internals/CefTimeUtils.cs b/CefSharp/Internals/CefTimeUtils.cs index a07aa8c55..a4af5bedb 100644 --- a/CefSharp/Internals/CefTimeUtils.cs +++ b/CefSharp/Internals/CefTimeUtils.cs @@ -32,6 +32,20 @@ namespace CefSharp.Internals return DateTime.FromFileTime(val * 10); } + /// + /// Converts from CefBaseTime to DateTime + /// + /// + /// Represents a wall clock time in UTC. Values are not guaranteed to be monotonically + /// non-decreasing and are subject to large amounts of skew. Time is stored internally + /// as microseconds since the Windows epoch (1601). + /// + /// returns a of + public static DateTime FromBaseTimeToDateTime(long val) + { + return DateTime.FromFileTime(val * 10); + } + public static DateTime ConvertCefTimeToDateTime(double epoch) { if (epoch == 0)