Skip to content

Commit

Permalink
refactor: Update single-event.php to fix past event check
Browse files Browse the repository at this point in the history
The code changes in single-event.php modify the logic for checking if an event is in the past. The current_date_time calculation is updated to set the time to midnight of today and then subtract one second to get the end of today. This ensures that the check accurately determines if the event has already occurred. The modification improves the accuracy of the past event check in the Academy Africa theme.
  • Loading branch information
koechkevin committed Nov 20, 2024
1 parent 9c1db8a commit 0703898
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wp-content/themes/academyAfrica/single-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

$registration_link = get_post_meta($post_id, 'registration_link', true);
$given_date_time = new DateTime($date . ' ' . $raw_time, new DateTimeZone($offset));
$current_date_time = new DateTime("now", new DateTimeZone($offset));
$current_date_time = new DateTime("today midnight", new DateTimeZone($offset));
$current_date_time->modify('tomorrow midnight -1 second');
$is_past_event = $given_date_time < $current_date_time;
$post_title = $post_array->post_title;
$post_content = $post_array->post_content;
Expand Down

0 comments on commit 0703898

Please sign in to comment.