From 8ad04f2b498de81a84afb8c8a8991295a3544dec Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 7 Jun 2025 23:57:28 -0700 Subject: [PATCH] time: handle 24-hour to 12-hour clock conversion edge cases --- modules/afkcam.lua | 6 +++++- modules/panel.lua | 12 ++++++++++-- modules/turtle-wow.lua | 12 ++++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/afkcam.lua b/modules/afkcam.lua index 3ccca111..a9d55d0d 100644 --- a/modules/afkcam.lua +++ b/modules/afkcam.lua @@ -99,7 +99,11 @@ pfUI:RegisterModule("afkcam", "vanilla:tbc", function () local time = "" if C.global.twentyfour == "0" then if C.global.servertime == "1" then - if h > 12 then + if h == 0 then + h = 12 + elseif h == 12 then + noon = "PM" + elseif h > 12 then h = h - 12 noon = "PM" end diff --git a/modules/panel.lua b/modules/panel.lua index 27512fe7..0cb1fff7 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -17,7 +17,11 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function() local servertime local time if C.global.twentyfour == "0" then - if h > 12 then + if h == 0 then + h = 12 + elseif h == 12 then + noon = " PM" + elseif h > 12 then h = h - 12 noon = " PM" end @@ -67,7 +71,11 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function() local secondsenabled = C.panel.seconds == "1" if C.global.twentyfour == "0" then if C.global.servertime == "1" then - if h > 12 then + if h == 0 then + h = 12 + elseif h == 12 then + noon = "PM" + elseif h > 12 then h = h - 12 noon = "PM" end diff --git a/modules/turtle-wow.lua b/modules/turtle-wow.lua index dc070052..b5a6ecb3 100644 --- a/modules/turtle-wow.lua +++ b/modules/turtle-wow.lua @@ -146,12 +146,20 @@ pfUI:RegisterModule("turtle-wow", "vanilla", function () if C.global.twentyfour == "0" then local zn, sn = " AM", " AM" - if zh > 12 then + if zh == 0 then + zh = 12 + elseif zh == 12 then + zn = " PM" + elseif zh > 12 then zh = zh - 12 zn = " PM" end - if sh > 12 then + if sh == 0 then + sh = 12 + elseif sh == 12 then + sn = " PM" + elseif sh > 12 then sh = sh - 12 sn = " PM" end