From 52dcb6845f6c80110a973c0785f6dc9de77aea2a Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Wed, 18 Sep 2024 12:21:10 -0600 Subject: [PATCH] Fix an issue with converting AM/PM time to 24 hour time. The logic to convert to 24 hour time didn't consider 12am and 12pm correctly, this fixes that. This fixes issue #2572 --- lib/WeBWorK/Utils/DateTime.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/WeBWorK/Utils/DateTime.pm b/lib/WeBWorK/Utils/DateTime.pm index f1e13977fe..404a3765b3 100644 --- a/lib/WeBWorK/Utils/DateTime.pm +++ b/lib/WeBWorK/Utils/DateTime.pm @@ -59,7 +59,8 @@ sub getDefaultSetDueDate ($ce) { my ($hour, $minute, $ampm) = $ce->{pg}{timeAssignDue} =~ m/\s*(\d+)\s*:\s*(\d+)\s*(am|pm|AM|PM)?\s*/; $hour //= 0; $minute //= 0; - $hour += 12 if $ampm && $ampm =~ m/pm|PM/; + $hour += 12 if $ampm && $ampm =~ m/pm|PM/ && $hour != 12; + $hour = 0 if $ampm && $ampm =~ m/am|AM/ && $hour == 12; my $dt = DateTime->from_epoch(epoch => time + 2 * 60 * 60 * 24 * 7);