Skip to content

Commit

Permalink
Merge pull request #2573 from somiaj/fix-conversion-to-24-hour-time
Browse files Browse the repository at this point in the history
Fix an issue with converting AM/PM time to 24 hour time.
  • Loading branch information
drgrice1 committed Sep 24, 2024
2 parents 87dce1d + 4ee8973 commit d9797ba
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 d9797ba

Please sign in to comment.