General: (sim642) Pull Request 489 - Implement actual timezone adjustment into PHPExcel_Shared_Date::PHPToExcel

This commit is contained in:
MarkBaker 2016-03-31 23:50:57 +01:00
parent 18a45ee7a1
commit 343955453a
2 changed files with 8 additions and 0 deletions

View File

@ -33,6 +33,7 @@ Planned for 1.9
- Feature: (Tomino2112) Work Item GH-808 - MemoryDrawing not working in HTML writer - 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 - 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 - 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): 2015-04-30 (v1.8.1):

View File

@ -184,10 +184,17 @@ class Date
{ {
$saveTimeZone = date_default_timezone_get(); $saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$timezoneAdjustment = ($adjustToTimezone) ?
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone ? $timezone : $saveTimeZone, $dateValue) :
0;
$retValue = false; $retValue = false;
if ((is_object($dateValue)) && ($dateValue instanceof \DateTime)) { 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')); $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)) { } 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)); $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)) { } elseif (is_string($dateValue)) {
$retValue = self::stringToExcel($dateValue); $retValue = self::stringToExcel($dateValue);