Exemplo n.º 1
0
 /// <summary>Returns a <see cref="string"/> that represents the <see cref="FILETIME"/> instance.</summary>
 /// <param name="ft">The <see cref="FILETIME"/> to convert.</param>
 /// <param name="format">A standard or custom date and time format string. See notes for <a href="https://msdn.microsoft.com/en-us/library/8tfzyc64(v=vs.110).aspx">DateTime.ToString()</a>.</param>
 /// <param name="provider">An object that supplies culture-specific formatting information.</param>
 /// <returns>
 /// A string representation of value of the current <see cref="FILETIME"/> object as specified by <paramref name="format"/> and <paramref name="provider"/>.
 /// </returns>
 public static string ToString(this FILETIME ft, string format, IFormatProvider provider = null) =>
 ft.ToInt64() < 0 ? ft.ToTimeSpan().ToString() : ft.ToDateTime().ToString(format, provider);
Exemplo n.º 2
0
 /// <summary>Converts a <see cref="FILETIME"/> structure to a <see cref="TimeSpan"/> structure.</summary>
 /// <param name="ft">The <see cref="FILETIME"/> value to convert.</param>
 /// <returns>The resulting <see cref="DateTime"/> structure.</returns>
 public static TimeSpan ToTimeSpan(this FILETIME ft) => new TimeSpan(ft.ToInt64());
Exemplo n.º 3
0
        /// <summary>Converts a <see cref="FILETIME"/> structure to a <see cref="DateTime"/> structure.</summary>
        /// <param name="ft">The <see cref="FILETIME"/> value to convert.</param>
        /// <param name="kind">The <see cref="DateTimeKind"/> value to use to determine local or UTC time.</param>
        /// <returns>The resulting <see cref="DateTime"/> structure.</returns>
        public static DateTime ToDateTime(this FILETIME ft, DateTimeKind kind = DateTimeKind.Local)
        {
            var hFT2 = ft.ToInt64();

            return(kind == DateTimeKind.Utc ? DateTime.FromFileTimeUtc(hFT2) : DateTime.FromFileTime(hFT2));
        }