Skip to content

Commit

Permalink
EZP-29545 Values of DateTime Field Type should be handled in UTC only
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbieniek committed Nov 30, 2018
1 parent d21957b commit b35b2b5
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions kernel/classes/datatypes/ezdatetime/ezdatetimetype.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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 );
}
}
Expand Down

0 comments on commit b35b2b5

Please sign in to comment.