Skip to content

Commit 7d082b4

Browse files
ENGCOM-6936: Date incorrect on pdf invoice issue26675 #26701
- Merge Pull Request #26701 from edenduong/magento2:2.4-bugfix/wrong_invoice_creditmemo_datetime_gb_issue26675 - Merged commits: 1. 5ebb43b
2 parents cde4f67 + 5ebb43b commit 7d082b4

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,9 @@ public function scopeDate($scope = null, $date = null, $includeTime = false)
206206
case ($date instanceof \DateTimeImmutable):
207207
$date = $date->setTimezone($timezone);
208208
break;
209-
case (!is_numeric($date)):
210-
$timeType = $includeTime ? \IntlDateFormatter::SHORT : \IntlDateFormatter::NONE;
211-
$formatter = new \IntlDateFormatter(
212-
$this->_localeResolver->getLocale(),
213-
\IntlDateFormatter::SHORT,
214-
$timeType,
215-
$timezone
216-
);
217-
$timestamp = $formatter->parse($date);
218-
$date = $timestamp
219-
? (new \DateTime('@' . $timestamp))->setTimezone($timezone)
220-
: new \DateTime($date, $timezone);
221-
break;
222-
case (is_numeric($date)):
223-
$date = new \DateTime('@' . $date);
224-
$date = $date->setTimezone($timezone);
225-
break;
226209
default:
227-
$date = new \DateTime($date, $timezone);
210+
$date = new \DateTime(is_numeric($date) ? '@' . $date : $date);
211+
$date->setTimezone($timezone);
228212
break;
229213
}
230214

lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,15 @@ public function scopeDateDataProvider(): array
314314

315315
return [
316316
['2018-10-20 00:00:00', 'UTC', 'en_US', '2018-10-20 00:00:00'],
317-
['2018-10-20 00:00:00', 'America/Los_Angeles', 'en_US', '2018-10-20 00:00:00'],
318-
['2018-10-20 00:00:00', 'Asia/Qatar', 'en_US', '2018-10-20 00:00:00'],
317+
['2018-10-20 00:00:00', 'America/Los_Angeles', 'en_US', '2018-10-19 17:00:00'],
318+
['2018-10-20 00:00:00', 'Asia/Qatar', 'en_US', '2018-10-20 03:00:00'],
319+
['2018-10-20 00:00:00', 'America/Los_Angeles', 'en_GB', '2018-10-19 17:00:00'],
319320
['10/20/18 00:00', 'UTC', 'en_US', '2018-10-20 00:00:00'],
320-
['10/20/18 00:00', 'America/Los_Angeles', 'en_US', '2018-10-20 00:00:00'],
321-
['10/20/18 00:00', 'Asia/Qatar', 'en_US', '2018-10-20 00:00:00'],
322-
['20/10/18 00:00', 'UTC', 'fr_FR', '2018-10-20 00:00:00'],
323-
['20/10/18 00:00', 'America/Los_Angeles', 'fr_FR', '2018-10-20 00:00:00'],
324-
['20/10/18 00:00', 'Asia/Qatar', 'fr_FR', '2018-10-20 00:00:00'],
321+
['10/20/18 00:00', 'America/Los_Angeles', 'en_US', '2018-10-19 17:00:00'],
322+
['10/20/18 00:00', 'Asia/Qatar', 'en_US', '2018-10-20 03:00:00'],
323+
['10/20/18 00:00', 'UTC', 'fr_FR', '2018-10-20 00:00:00'],
324+
['10/20/18 00:00', 'America/Los_Angeles', 'fr_FR', '2018-10-19 17:00:00'],
325+
['10/20/18 00:00', 'Asia/Qatar', 'fr_FR', '2018-10-20 03:00:00'],
325326
[1539993600, 'UTC', 'en_US', '2018-10-20 00:00:00'],
326327
[1539993600, 'America/Los_Angeles', 'en_US', '2018-10-19 17:00:00'],
327328
[1539993600, 'Asia/Qatar', 'en_US', '2018-10-20 03:00:00'],

0 commit comments

Comments
 (0)