// Copyright © 2016 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using System; namespace CefSharp.Internals { /// /// Mapping to/from CefBaseTime /// public static class CefTimeUtils { /// /// 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). /// /// if is 0 then returns null otherwise returns a of public static DateTime? FromBaseTimeToNullableDateTime(long val) { if(val == 0) { return null; } 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); } /// /// Converts from DateTime to CefBaseTime /// /// DateTime /// /// Represents a wall clock time in UTC. Time as microseconds since the Windows epoch (1601). /// public static long FromDateTimeToBaseTime(DateTime dateTime) { // Same as calling ToFileTime, this to me is a little // more self descriptive of what's going on. return dateTime.ToUniversalTime().ToFileTimeUtc() / 10; } } }