From b09f614ef5515cdecd74d378b392561beb760637 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Wed, 4 Sep 2019 14:31:16 -0400 Subject: [PATCH] feat: Added a method for determining if a culture uses 24 hour format --- CHANGELOG.md | 1 + .../Extensions/CultureInfoExtensions.cs | 17 +++++++++++++++++ .../ICD.Common.Utils_SimplSharp.csproj | 1 + 3 files changed, 19 insertions(+) create mode 100644 ICD.Common.Utils/Extensions/CultureInfoExtensions.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index dfbe750..d7094d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - Added a method for converting 24 hour to 12 hour format + - Added a method for determining if a culture uses 24 hour format ## [9.8.0] - 2019-09-03 ### Added diff --git a/ICD.Common.Utils/Extensions/CultureInfoExtensions.cs b/ICD.Common.Utils/Extensions/CultureInfoExtensions.cs new file mode 100644 index 0000000..4199c54 --- /dev/null +++ b/ICD.Common.Utils/Extensions/CultureInfoExtensions.cs @@ -0,0 +1,17 @@ +using System.Globalization; + +namespace ICD.Common.Utils.Extensions +{ + public static class CultureInfoExtensions + { + /// + /// Returns true if the given culture uses a 24 hour time format. + /// + /// + /// + public static bool Uses24HourFormat(this CultureInfo extends) + { + return extends.DateTimeFormat.ShortTimePattern.Contains("H"); + } + } +} diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj index ec7247f..9ec13c9 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj @@ -110,6 +110,7 @@ +