location->get(); if ( null === $location['latitude'] || null === $location['longitude'] ) { throw new CatalogException( 'abece_booking_location_required', __( 'Set the club location before using sun-based opening hours.', 'abece-booking' ), 503 ); } $anchor = Time::local( $date, '12:00' ); if ( ! $anchor ) { return null; } // Check adjacent UTC days too: local dates may differ near the date line. foreach ( [ 0, -86400, 86400 ] as $offset ) { $info = date_sun_info( $anchor->getTimestamp() + $offset, (float) $location['latitude'], (float) $location['longitude'] ); if ( is_int( $info['sunrise'] ) && is_int( $info['sunset'] ) && Time::timestamp( $info['sunrise'] )->format( 'Y-m-d' ) === $date ) { return [ 'sunrise' => $info['sunrise'], 'sunset' => $info['sunset'] ]; } } // No finite sunrise/sunset in polar day/night: offer no sun-based slots. return null; } }