Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-29545 Values of DateTime Field Type should be handled in UTC only #1405

Open
wants to merge 1 commit into
base: 2017.12
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 )
glye marked this conversation as resolved.
Show resolved Hide resolved
);
$objectAttribute->setAttribute( 'data_int', $timestamp );
}
}
Expand Down