Jake Vanderwerf
2026-09-15 01e9a8e40351a87f6548a4f55de842d6f6918ad0
inc/helpers/time.php
@@ -26,6 +26,7 @@
 * Format a date in relative time (e.g., "2 days ago")
 * @param string $dateStr - Date string or DateTime object
 * @return string - Formatted relative time
 * @throws DateMalformedStringException
 */
function jvbFormatTimeAgo(string $dateStr):string
{
@@ -174,7 +175,7 @@
   $out = '';
   if (!empty($hours) && jvbHasOperatingHours($hours)) {
      $out = jvbGetFormattedHours($hours, true, true);
      $out = jvbGetFormattedHours($hours);
   } else {
      $out = '<p class="no-hours">Hours not available</p>';
   }
@@ -311,9 +312,11 @@
/**
 * Check if business is currently open based on stored hours
 *
 * @param array $hours_data Array of hours data from wp_option
 * @param array|null $hours_data Array of hours data from wp_option
 * @param string $timezone Timezone string (default: 'America/Edmonton')
 * @return bool True if currently open, false if closed
 * @throws DateInvalidTimeZoneException
 * @throws DateMalformedStringException
 */
function jvbIsCurrentlyOpen(?array $hours_data = null, string $timezone = 'America/Edmonton'):bool
{
@@ -368,8 +371,10 @@
 * @param ?string $end_time End time in H:i format (e.g., '15:15')
 * @param string $timezone Timezone string (default: 'America/Edmonton')
 * @return bool True if current time is within range, false otherwise
 * @throws DateInvalidTimeZoneException
 * @throws DateMalformedStringException
 */
function jvbIsTimeBetween(?string $start_time = null, ?string $end_time = null, string $timezone = 'America/Edmonton'):bool {
function jvbIsTimeBetween(?string $start_time = null, ?string $end_time = null):bool {
   if (!$start_time && !$end_time) {
      $hours = Options::get('today_hours');
      $start_time = $hours['time_start'];
@@ -377,7 +382,7 @@
   }
   // Get current time in specified timezone
   $current_time = new DateTime('now', new DateTimeZone($timezone));
   $current_time = new DateTime('now', wp_timezone());
   $current_time_string = $current_time->format('H:i');
   // Normalize time formats (handle with or without seconds)
@@ -401,6 +406,7 @@
 * @param string $timezone Timezone string
 * @return string Next opening time description or empty string if never opens
 * @throws DateInvalidTimeZoneException
 * @throws DateMalformedStringException
 */
function jvbGetNextOpeningTime(array $hours_data, string $timezone = 'America/Edmonton'):string {
   if (!jvbHasOperatingHours($hours_data)) {