From b35b2b52605c8852bd38f95d5d9003f6ce82119b Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Fri, 30 Nov 2018 11:22:47 +0100 Subject: [PATCH] EZP-29545 Values of DateTime Field Type should be handled in UTC only --- .../datatypes/ezdatetime/ezdatetimetype.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/kernel/classes/datatypes/ezdatetime/ezdatetimetype.php b/kernel/classes/datatypes/ezdatetime/ezdatetimetype.php index bdca7897681..a6ff44df40f 100644 --- a/kernel/classes/datatypes/ezdatetime/ezdatetimetype.php +++ b/kernel/classes/datatypes/ezdatetime/ezdatetimetype.php @@ -153,7 +153,7 @@ function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute ) { $dateTime = new eZDateTime(); $dateTime->setMDYHMS( $month, $day, $year, $hour, $minute, $second ); - $stamp = $dateTime->timeStamp(); + $stamp = eZTimestamp::getUtcTimestampFromLocalTimestamp( $dateTime->timeStamp() ); } $contentObjectAttribute->setAttribute( 'data_int', $stamp ); @@ -246,7 +246,7 @@ function fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $ { $dateTime = new eZDateTime(); $dateTime->setMDYHMS( $month, $day, $year, $hour, $minute, $second ); - $stamp = $dateTime->timeStamp(); + $stamp = eZTimestamp::getUtcTimestampFromLocalTimestamp( $dateTime->timeStamp() ); } $collectionAttribute->setAttribute( 'data_int', $stamp ); @@ -262,7 +262,9 @@ function objectAttributeContent( $contentObjectAttribute ) { $dateTime = new eZDateTime(); $stamp = $contentObjectAttribute->attribute( 'data_int' ); - $dateTime->setTimeStamp( $stamp ); + $dateTime->setTimeStamp( + eZTimestamp::getLocalTimestampFromUtcTimestamp( $stamp ) + ); return $dateTime; } @@ -581,7 +583,13 @@ function serializeContentObjectAttribute( $package, $objectAttribute ) { $dom = $node->ownerDocument; $dateTimeNode = $dom->createElement( 'date_time' ); - $dateTimeNode->appendChild( $dom->createTextNode( eZDateUtils::rfc1123Date( $stamp ) ) ); + $dateTimeNode->appendChild( + $dom->createTextNode( + eZDateUtils::rfc1123Date( + eZTimestamp::getLocalTimestampFromUtcTimestamp( $stamp ) + ) + ) + ); $node->appendChild( $dateTimeNode ); } return $node; @@ -592,7 +600,9 @@ function unserializeContentObjectAttribute( $package, $objectAttribute, $attribu $dateTimeNode = $attributeNode->getElementsByTagName( 'date_time' )->item( 0 ); if ( is_object( $dateTimeNode ) ) { - $timestamp = eZDateUtils::textToDate( $dateTimeNode->textContent ); + $timestamp = eZTimestamp::getUtcTimestampFromLocalTimestamp( + eZDateUtils::textToDate( $dateTimeNode->textContent ) + ); $objectAttribute->setAttribute( 'data_int', $timestamp ); } }