From c4782b660619be139a64d96a545f6a422ca74c20 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Thu, 31 Mar 2016 23:50:44 +0100 Subject: [PATCH] General: (sim642) Pull Request 489 - Implement actual timezone adjustment into PHPExcel_Shared_Date::PHPToExcel --- Classes/PHPExcel/Shared/Date.php | 7 +++++++ changelog.txt | 1 + 2 files changed, 8 insertions(+) diff --git a/Classes/PHPExcel/Shared/Date.php b/Classes/PHPExcel/Shared/Date.php index c772bd4..b00a39a 100644 --- a/Classes/PHPExcel/Shared/Date.php +++ b/Classes/PHPExcel/Shared/Date.php @@ -182,10 +182,17 @@ class PHPExcel_Shared_Date { $saveTimeZone = date_default_timezone_get(); date_default_timezone_set('UTC'); + + $timezoneAdjustment = ($adjustToTimezone) ? + PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone ? $timezone : $saveTimeZone, $dateValue) : + 0; + $retValue = false; if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) { + $dateValue->add(new DateInterval('PT' . $timezoneAdjustment . 'S')); $retValue = self::FormattedPHPToExcel($dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')); } elseif (is_numeric($dateValue)) { + $dateValue += $timezoneAdjustment; $retValue = self::FormattedPHPToExcel(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), date('H', $dateValue), date('i', $dateValue), date('s', $dateValue)); } elseif (is_string($dateValue)) { $retValue = self::stringToExcel($dateValue); diff --git a/changelog.txt b/changelog.txt index 3a5456f..1d5c9fe 100644 --- a/changelog.txt +++ b/changelog.txt @@ -34,6 +34,7 @@ Planned for 1.8.2 - Feature: (Tomino2112) Work Item GH-808 - MemoryDrawing not working in HTML writer - General: (rentalhost) Work Item GH-575 - Excel 2007 Reader freezes because of conditional formatting - Bugfix: (vitalyrepin) Pull Request 869 - c:max and c:min elements shall NOT be inside c:orientation elements +- General: (sim642) Pull Request 489 - Implement actual timezone adjustment into PHPExcel_Shared_Date::PHPToExcel 2015-04-30 (v1.8.1):