From e52187b85f9bb9ef92aae43da394ddcc440841bd Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 2 Jun 2022 20:13:37 -0400 Subject: [PATCH] move dateFormatters to config. This is so that they get setup even if not using index.php. Like cakephp for example. --- web/includes/config.php.in | 21 +++++++++++++++++++++ web/index.php | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/web/includes/config.php.in b/web/includes/config.php.in index 8a219b2a0..6220de5a8 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -136,9 +136,30 @@ define('SCALE_BASE', 100); // The additional scaling factor used to he define('STRF_FMT_DATETIME_DB', 'Y-m-d H:i:s'); // Strftime format for database queries, don't change define('MYSQL_FMT_DATETIME_SHORT', 'Y/m/d H:i:s'); // MySQL date_format shorter format for dates with time +global $dateFormatter; +global $dateTimeFormatter; +global $timeFormatter; +$dateFormatter = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::NONE); +$dateTimeFormatter = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::LONG); +$timeFormatter = new IntlDateFormatter(null, IntlDateFormatter::NONE, IntlDateFormatter::LONG); + require_once('database.php'); require_once('logger.php'); loadConfig(); +if (ZM_LOCALE_DEFAULT) { + $dateFormatter = new IntlDateFormatter(ZM_LOCALE_DEFAULT, IntlDateFormatter::SHORT, IntlDateFormatter::NONE); + $dateTimeFormatter = new IntlDateFormatter(ZM_LOCALE_DEFAULT, IntlDateFormatter::SHORT, IntlDateFormatter::LONG); + $timeFormatter = new IntlDateFormatter(ZM_LOCALE_DEFAULT, IntlDateFormatter::NONE, IntlDateFormatter::LONG); +} +if (ZM_DATE_FORMAT_PATTERN) { + $dateFormatter->setPatter(ZM_DATE_FORMAT_PATTERN); +} +if (ZM_DATETIME_FORMAT_PATTERN) { + $dateTimeFormatter->setPattern(ZM_DATETIME_FORMAT_PATTERN); +} +if (ZM_TIME_FORMAT_PATTERN) { + $timeFormatter->setPattern(ZM_TIME_FORMAT_PATTERN); +} ZM\Logger::fetch()->initialise(); $GLOBALS['defaultUser'] = array( diff --git a/web/index.php b/web/index.php index 8bc2145bd..5ace8e9b6 100644 --- a/web/index.php +++ b/web/index.php @@ -43,28 +43,7 @@ if ( false ) { ob_end_clean(); } -global $dateFormatter; -global $dateTimeFormatter; -global $timeFormatter; -$dateFormatter = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::NONE); -$dateTimeFormatter = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::LONG); -$timeFormatter = new IntlDateFormatter(null, IntlDateFormatter::NONE, IntlDateFormatter::LONG); require_once('includes/config.php'); -if (ZM_LOCALE_DEFAULT) { - setlocale(LC_ALL, ZM_LOCALE_DEFAULT); - $dateFormatter = new IntlDateFormatter(ZM_LOCALE_DEFAULT, IntlDateFormatter::SHORT, IntlDateFormatter::NONE); - $dateTimeFormatter = new IntlDateFormatter(ZM_LOCALE_DEFAULT, IntlDateFormatter::SHORT, IntlDateFormatter::LONG); - $timeFormatter = new IntlDateFormatter(ZM_LOCALE_DEFAULT, IntlDateFormatter::NONE, IntlDateFormatter::LONG); -} -if (ZM_DATE_FORMAT_PATTERN) { - $dateFormatter->setPatter(ZM_DATE_FORMAT_PATTERN); -} -if (ZM_DATETIME_FORMAT_PATTERN) { - $dateTimeFormatter->setPattern(ZM_DATETIME_FORMAT_PATTERN); -} -if (ZM_TIME_FORMAT_PATTERN) { - $timeFormatter->setPattern(ZM_TIME_FORMAT_PATTERN); -} require_once('includes/session.php'); require_once('includes/logger.php'); require_once('includes/Server.php');