diff --git a/ICD.Common.Utils/DateTimeUtils.cs b/ICD.Common.Utils/DateTimeUtils.cs index 06efee2..4dd01ef 100644 --- a/ICD.Common.Utils/DateTimeUtils.cs +++ b/ICD.Common.Utils/DateTimeUtils.cs @@ -1,4 +1,6 @@ -namespace ICD.Common.Utils +using System; + +namespace ICD.Common.Utils { public static class DateTimeUtils { @@ -11,5 +13,25 @@ { return MathUtils.Modulus(hour + 11, 12) + 1; } + + /// + /// Creates a DateTime from the given number of milliseconds since the epoch (1970-01-01T00:00:00Z) + /// + /// milliseconds since the epoch + /// + public static DateTime FromEpochMilliseconds(long milliseconds) + { + return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(milliseconds); + } + + /// + /// Creates a DateTime from the given number of seconds since the epoch (1970-01-01T00:00:00Z) + /// + /// seconds since the epoch + /// + public static DateTime FromEpochSeconds(long seconds) + { + return FromEpochMilliseconds(seconds * 1000); + } } }