diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php index 2568a5ccf21c1..0791c89ab793a 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php @@ -206,25 +206,9 @@ public function scopeDate($scope = null, $date = null, $includeTime = false) case ($date instanceof \DateTimeImmutable): $date = $date->setTimezone($timezone); break; - case (!is_numeric($date)): - $timeType = $includeTime ? \IntlDateFormatter::SHORT : \IntlDateFormatter::NONE; - $formatter = new \IntlDateFormatter( - $this->_localeResolver->getLocale(), - \IntlDateFormatter::SHORT, - $timeType, - $timezone - ); - $timestamp = $formatter->parse($date); - $date = $timestamp - ? (new \DateTime('@' . $timestamp))->setTimezone($timezone) - : new \DateTime($date, $timezone); - break; - case (is_numeric($date)): - $date = new \DateTime('@' . $date); - $date = $date->setTimezone($timezone); - break; default: - $date = new \DateTime($date, $timezone); + $date = new \DateTime(is_numeric($date) ? '@' . $date : $date); + $date->setTimezone($timezone); break; } diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php index 566992c70b5e3..12ba34778b66e 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php @@ -314,14 +314,15 @@ public function scopeDateDataProvider(): array return [ ['2018-10-20 00:00:00', 'UTC', 'en_US', '2018-10-20 00:00:00'], - ['2018-10-20 00:00:00', 'America/Los_Angeles', 'en_US', '2018-10-20 00:00:00'], - ['2018-10-20 00:00:00', 'Asia/Qatar', 'en_US', '2018-10-20 00:00:00'], + ['2018-10-20 00:00:00', 'America/Los_Angeles', 'en_US', '2018-10-19 17:00:00'], + ['2018-10-20 00:00:00', 'Asia/Qatar', 'en_US', '2018-10-20 03:00:00'], + ['2018-10-20 00:00:00', 'America/Los_Angeles', 'en_GB', '2018-10-19 17:00:00'], ['10/20/18 00:00', 'UTC', 'en_US', '2018-10-20 00:00:00'], - ['10/20/18 00:00', 'America/Los_Angeles', 'en_US', '2018-10-20 00:00:00'], - ['10/20/18 00:00', 'Asia/Qatar', 'en_US', '2018-10-20 00:00:00'], - ['20/10/18 00:00', 'UTC', 'fr_FR', '2018-10-20 00:00:00'], - ['20/10/18 00:00', 'America/Los_Angeles', 'fr_FR', '2018-10-20 00:00:00'], - ['20/10/18 00:00', 'Asia/Qatar', 'fr_FR', '2018-10-20 00:00:00'], + ['10/20/18 00:00', 'America/Los_Angeles', 'en_US', '2018-10-19 17:00:00'], + ['10/20/18 00:00', 'Asia/Qatar', 'en_US', '2018-10-20 03:00:00'], + ['10/20/18 00:00', 'UTC', 'fr_FR', '2018-10-20 00:00:00'], + ['10/20/18 00:00', 'America/Los_Angeles', 'fr_FR', '2018-10-19 17:00:00'], + ['10/20/18 00:00', 'Asia/Qatar', 'fr_FR', '2018-10-20 03:00:00'], [1539993600, 'UTC', 'en_US', '2018-10-20 00:00:00'], [1539993600, 'America/Los_Angeles', 'en_US', '2018-10-19 17:00:00'], [1539993600, 'Asia/Qatar', 'en_US', '2018-10-20 03:00:00'],