From 81d30db590a44c953828f02d2d890fb6d7157589 Mon Sep 17 00:00:00 2001 From: Olivier Nolbert <81619726+olivier-dbcom@users.noreply.github.com> Date: Sat, 7 Oct 2023 12:59:18 +0200 Subject: [PATCH] Fix date Format to use User Time Zone --- plugins/cck_field/calendar/calendar.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/cck_field/calendar/calendar.php b/plugins/cck_field/calendar/calendar.php index 92989f591..bcad79be9 100644 --- a/plugins/cck_field/calendar/calendar.php +++ b/plugins/cck_field/calendar/calendar.php @@ -307,11 +307,15 @@ public function onCCK_FieldPrepareStore( &$field, $value = '', &$config = array( $locale = $this->setLocale(); // If data was created by script we have in fixed format, else we need to parse string - if ( $datasource == "computed" ) { - $date = JDate::createFromFormat( 'Y-m-d H:i:s', $value, $this->userTimeZone ); - } else { - $date = JDate::createFromFormat( $options2['format'], $value, $this->userTimeZone ); - } + // if ( $datasource == "computed" ) { + // $date = JDate::createFromFormat( 'Y-m-d H:i:s', $value, $this->userTimeZone ); + // } else { + // $date = JDate::createFromFormat( $options2['format'], $value, $this->userTimeZone ); + // } + + //OCTOPOOS : Bloc if..then..else ci-dessus commenté et remplacé par celle ci-dessous suite passage à PHP8 et mauvais format de date (timezone non pris en compte) + //Cette modification n'impacte pas les sites encore en 7.4 qui continue à fonctionner de la même manière + $date = DateTime::createFromFormat( $datasource == "computed" ? 'Y-m-d H:i:s' : $options2['format'], $value, $this->userTimeZone ); if ( $date == false ) { throw new OutOfBoundsException( 'You either used wrong format or locale set by language file is not supported on your server - ' .$locale );