From 4ff4e9f3c6612d352fd1ed7857526afb2d84888a Mon Sep 17 00:00:00 2001 From: Austin Noska Date: Thu, 18 Feb 2021 16:18:38 -0500 Subject: [PATCH] feat: Add method to IcdEnvironment to get the name of the local time zone --- ICD.Common.Utils/IcdEnvironment.SimplSharp.cs | 9 +++++++++ ICD.Common.Utils/IcdEnvironment.Standard.cs | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs index a30fb96..54d3863 100644 --- a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs +++ b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs @@ -210,6 +210,15 @@ namespace ICD.Common.Utils #region Methods + /// + /// Gets the name of the local time zone. + /// + /// + public static string GetLocalTimeZoneName() + { + return CrestronEnvironment.GetTimeZone().Name; + } + public static DateTime GetLocalTime() { return CrestronEnvironment.GetLocalTime(); diff --git a/ICD.Common.Utils/IcdEnvironment.Standard.cs b/ICD.Common.Utils/IcdEnvironment.Standard.cs index 60f1ae7..d75e7cd 100644 --- a/ICD.Common.Utils/IcdEnvironment.Standard.cs +++ b/ICD.Common.Utils/IcdEnvironment.Standard.cs @@ -93,6 +93,17 @@ namespace ICD.Common.Utils s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Na; } + /// + /// Gets the name of the local time zone. + /// + /// + public static string GetLocalTimeZoneName() + { + return System.TimeZoneInfo.Local.IsDaylightSavingTime(GetLocalTime()) + ? System.TimeZoneInfo.Local.DaylightName + : System.TimeZoneInfo.Local.StandardName; + } + public static DateTime GetLocalTime() { return DateTime.Now;