Skip to content

Commit

Permalink
Fix an issue with converting AM/PM time to 24 hour time.
Browse files Browse the repository at this point in the history
The logic to convert to 24 hour time didn't consider 12am and 12pm
correctly, this fixes that.

This fixes issue openwebwork#2572
  • Loading branch information
somiaj committed Sep 19, 2024
1 parent 647d317 commit 52dcb68
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/WeBWorK/Utils/DateTime.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 52dcb68

Please sign in to comment.