From 569311c61e68f2e1b08926d3d093c1709746bf12 Mon Sep 17 00:00:00 2001 From: bradjrenshaw Date: Thu, 12 May 2022 20:04:33 -0400 Subject: [PATCH] Fix incorrect AM and PM time announcement and :00 formatting. --- stardew-access/Features/CurrentPlayer.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/stardew-access/Features/CurrentPlayer.cs b/stardew-access/Features/CurrentPlayer.cs index 7a2f525..5331576 100644 --- a/stardew-access/Features/CurrentPlayer.cs +++ b/stardew-access/Features/CurrentPlayer.cs @@ -96,15 +96,10 @@ namespace stardew_access.Features int minutes = timeOfDay % 100; int hours = timeOfDay / 100; - string amOrpm = "A M"; - if (hours >= 12) - { - amOrpm = "P M"; - if (hours > 12) - hours -= 12; - } - - return $"{hours}:{minutes} {amOrpm}"; + string amOrpm = hours / 12 == 1 ? "PM" : "AM"; + hours = hours % 12; + if (hours == 0) hours = 12; + return $"{hours}:{minutes:00} {amOrpm}"; } }