diff --git a/CHANGELOG.md b/CHANGELOG.md
index 37d7988..dfbe750 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Added
- - Added an extension method for getting the hour in 12 hour format
+ - Added a method for converting 24 hour to 12 hour format
## [9.8.0] - 2019-09-03
### Added
diff --git a/ICD.Common.Utils.Tests/DateTimeUtilsTest.cs b/ICD.Common.Utils.Tests/DateTimeUtilsTest.cs
new file mode 100644
index 0000000..a3957ee
--- /dev/null
+++ b/ICD.Common.Utils.Tests/DateTimeUtilsTest.cs
@@ -0,0 +1,17 @@
+using NUnit.Framework;
+
+namespace ICD.Common.Utils.Tests
+{
+ [TestFixture]
+ public sealed class DateTimeUtilsTest
+ {
+ [TestCase(1, 1)]
+ [TestCase(0, 12)]
+ [TestCase(12, 12)]
+ [TestCase(23, 11)]
+ public void Get12Hour(int hour, int expected)
+ {
+ Assert.AreEqual(expected, DateTimeUtils.To12Hour(hour));
+ }
+ }
+}
diff --git a/ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs
index a186f96..f712305 100644
--- a/ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs
+++ b/ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs
@@ -1,21 +1,10 @@
-using System;
-using ICD.Common.Utils.Extensions;
-using NUnit.Framework;
+using NUnit.Framework;
namespace ICD.Common.Utils.Tests.Extensions
{
[TestFixture]
public sealed class DateTimeExtensionsTest
{
- [TestCase(1, 1)]
- [TestCase(0, 12)]
- [TestCase(12, 12)]
- [TestCase(23, 11)]
- public void Get12Hour(int hour, int expected)
- {
- Assert.AreEqual(expected, new DateTime(2019, 1, 1, hour, 0, 0).Get12Hour());
- }
-
[Test]
public void ToShortTimeStringTest()
{
diff --git a/ICD.Common.Utils/DateTimeUtils.cs b/ICD.Common.Utils/DateTimeUtils.cs
new file mode 100644
index 0000000..edcda83
--- /dev/null
+++ b/ICD.Common.Utils/DateTimeUtils.cs
@@ -0,0 +1,15 @@
+namespace ICD.Common.Utils
+{
+ public static class DateTimeUtils
+ {
+ ///
+ /// Converts the hour in 24 hour format to 12 hour format (1 through 12).
+ ///
+ ///
+ ///
+ public static int To12Hour(int hour)
+ {
+ return ((hour + 11) % 12) + 1;
+ }
+ }
+}
diff --git a/ICD.Common.Utils/Extensions/DateTimeExtensions.cs b/ICD.Common.Utils/Extensions/DateTimeExtensions.cs
index ecba069..acdc661 100644
--- a/ICD.Common.Utils/Extensions/DateTimeExtensions.cs
+++ b/ICD.Common.Utils/Extensions/DateTimeExtensions.cs
@@ -10,16 +10,6 @@ namespace ICD.Common.Utils.Extensions
///
public static class DateTimeExtensions
{
- ///
- /// Gets the hour in 12 hour format (1 through 12).
- ///
- ///
- ///
- public static int Get12Hour(this DateTime extends)
- {
- return ((extends.Hour + 11) % 12) + 1;
- }
-
///
/// Replacement for missing DateTime.ToShortTimeString() absent from NetStandard.
///
diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj
index 0614074..ec7247f 100644
--- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj
+++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj
@@ -86,6 +86,7 @@
+
diff --git a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs
index b85dc8f..39dcf48 100644
--- a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs
+++ b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs
@@ -190,6 +190,16 @@ namespace ICD.Common.Utils
return CrestronEnvironment.GetLocalTime();
}
+ public static void SetLocalTime(DateTime localTime)
+ {
+ CrestronEnvironment.SetTimeAndDate((ushort)localTime.Hour,
+ (ushort)localTime.Minute,
+ (ushort)localTime.Second,
+ (ushort)localTime.Month,
+ (ushort)localTime.Day,
+ (ushort)localTime.Year);
+ }
+
public static eEthernetEventType GetEthernetEventType(Crestron.SimplSharp.eEthernetEventType type)
{
switch (type)
diff --git a/ICD.Common.Utils/IcdEnvironment.Standard.cs b/ICD.Common.Utils/IcdEnvironment.Standard.cs
index a7a618a..62d607c 100644
--- a/ICD.Common.Utils/IcdEnvironment.Standard.cs
+++ b/ICD.Common.Utils/IcdEnvironment.Standard.cs
@@ -79,6 +79,16 @@ namespace ICD.Common.Utils
return DateTime.Now;
}
+ public static void SetLocalTime(DateTime localTime)
+ {
+#if DEBUG
+ IcdConsole.PrintLine(eConsoleColor.Magenta, "Debug Build - Skipped setting local time to {0}",
+ localTime.ToString("s"));
+#else
+ throw new NotSupportedException();
+#endif
+ }
+
///
/// Converts 12 digit address to XX:XX:XX... format
///