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:44 +01:00
parent a1dee8f6c3
commit c4782b6606
2 changed files with 8 additions and 0 deletions

View File

@ -182,10 +182,17 @@ class PHPExcel_Shared_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);

View File

@ -34,6 +34,7 @@ Planned for 1.8.2
- 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):