From e845e8876ddd9f1042a93d12f13b4f34404e086f Mon Sep 17 00:00:00 2001 From: bancer Date: Fri, 25 Jan 2019 13:04:41 +0100 Subject: [PATCH] Add unit test --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 4c89398b5..4bc9f8a62 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -421,6 +421,18 @@ class CakeTimeTest extends CakeTestCase { $this->_restoreSystemTimezone(); } + public function testNiceTimezoneConversion() { + date_default_timezone_set('Europe/Copenhagen'); // server timezone + $clientTimeZone = new DateTimeZone('Asia/Bangkok'); + $clientDateTime = new DateTime('2019-01-31 10:00:00', $clientTimeZone); + // Convert to UTC. + $actual = CakeTime::nice($clientDateTime, 'UTC', '%Y-%m-%d %H:%M:%S'); + $clientDateTime->setTimezone(new DateTimeZone('UTC')); + $expected = $clientDateTime->format('Y-m-d H:i:s'); + $this->assertEquals($expected, $actual); + $this->_restoreSystemTimezone(); + } + /** * testNiceShort method *