feat: Added an extension method for getting the hour in 12 hour format

This commit is contained in:
Chris Cameron
2019-09-04 12:36:54 -04:00
parent 091ad10068
commit dc1b60e629
3 changed files with 33 additions and 9 deletions

View File

@@ -10,6 +10,16 @@ namespace ICD.Common.Utils.Extensions
/// </summary>
public static class DateTimeExtensions
{
/// <summary>
/// Gets the hour in 12 hour format (1 through 12).
/// </summary>
/// <param name="extends"></param>
/// <returns></returns>
public static int Get12Hour(this DateTime extends)
{
return ((extends.Hour + 11) % 12) + 1;
}
/// <summary>
/// Replacement for missing DateTime.ToShortTimeString() absent from NetStandard.
/// </summary>