123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
- using System;
- namespace Org.BouncyCastle.Utilities.Date
- {
- public class DateTimeUtilities
- {
- public static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1);
- private DateTimeUtilities()
- {
- }
-
-
-
-
-
-
- public static long DateTimeToUnixMs(
- DateTime dateTime)
- {
- if (dateTime.CompareTo(UnixEpoch) < 0)
- throw new ArgumentException("DateTime value may not be before the epoch", "dateTime");
- return (dateTime.Ticks - UnixEpoch.Ticks) / TimeSpan.TicksPerMillisecond;
- }
-
-
-
-
-
- public static DateTime UnixMsToDateTime(
- long unixMs)
- {
- return new DateTime(unixMs * TimeSpan.TicksPerMillisecond + UnixEpoch.Ticks);
- }
-
-
-
- public static long CurrentUnixMs()
- {
- return DateTimeToUnixMs(DateTime.UtcNow);
- }
- }
- }
- #endif
|