From 0284c3f460b9806bb64909fc2b7d6d97f4b94f77 Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Tue, 17 Oct 2023 00:17:55 +0300 Subject: [PATCH] Load and use the strftime replacement function only if needed --- schedule/parse.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/schedule/parse.php b/schedule/parse.php index 59a699e..923f53e 100644 --- a/schedule/parse.php +++ b/schedule/parse.php @@ -1,8 +1,15 @@ ='); + +if ($strftimeDeprecated) { + require 'php-8.1-strftime.php'; +} + +$strftime = fn(...$args) => $strftimeDeprecated ? PHP81_BC\strftime(...$args) : \strftime(...$args); function parseData($config, $data) { + global $strftime; + $languages = array( 'en' => array( 'name' => 'English', @@ -237,7 +244,7 @@ function parseData($config, $data) { $columns = []; if (date('d.m', $microslots[$slot_index][0]) !== date('d.m', $lastTs)) { - $schedule_body .= '' . strftime('%d %B - %A', $microslots[$slot_index][0]) . ''; + $schedule_body .= '' . $strftime('%d %B - %A', $microslots[$slot_index][0]) . ''; } $lastTs = $microslots[$slot_index][0];