Skip to content

Commit

Permalink
Merge pull request #947 from heliopsis/EZP-6959
Browse files Browse the repository at this point in the history
Fix EZP-6959: eZDate and eZDateTime accept values prior to epoch
  • Loading branch information
andrerom committed May 20, 2014
2 parents 480fbfc + 4a95844 commit 2eff97b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions kernel/classes/datatypes/ezdatetime/ezdatetimetype.php
Expand Up @@ -147,7 +147,7 @@ function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )

if ( ( $year == '' and $month == '' and $day == '' and
$hour == '' and $minute == '' and ( !$useSeconds or $second == '' ) ) or
!checkdate( $month, $day, $year ) or $year < 1970 )
!checkdate( $month, $day, $year ) )
{
$dateTime->setTimeStamp( 0 );
}
Expand Down Expand Up @@ -239,7 +239,7 @@ function fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $
$contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
if ( ( $year == '' and $month == ''and $day == '' and
$hour == '' and $minute == '' and ( !$useSeconds or $second == '' ) ) or
!checkdate( $month, $day, $year ) or $year < 1970 )
!checkdate( $month, $day, $year ) )
{
$dateTime->setTimeStamp( 0 );
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ezlocale/classes/ezdate.php
Expand Up @@ -73,7 +73,7 @@ function eZDate( $date = false )
}
$this->Date = $date;
$this->Locale = eZLocale::instance();
$this->IsValid = $date > 0;
$this->IsValid = true;
}

function attributes()
Expand Down Expand Up @@ -144,7 +144,7 @@ function timeStamp()
function setTimeStamp( $stamp )
{
$this->Date = $stamp;
$this->IsValid = $stamp > 0;
$this->IsValid = true;
}

/*!
Expand Down
6 changes: 3 additions & 3 deletions lib/ezlocale/classes/ezdatetime.php
Expand Up @@ -85,9 +85,9 @@ function eZDateTime( $datetime = false )
$datetime = time();
}

$this->DateTime = $datetime;
$this->DateTime = intval( $datetime );
$this->Locale = eZLocale::instance();
$this->IsValid = $datetime > 0;
$this->IsValid = true;
}

function attributes()
Expand Down Expand Up @@ -192,7 +192,7 @@ function timeStamp( )
function setTimeStamp( $stamp )
{
$this->DateTime = $stamp;
$this->IsValid = $stamp > 0;
$this->IsValid = true;
}

/*!
Expand Down
2 changes: 0 additions & 2 deletions lib/ezutils/classes/ezdatetimevalidator.php
Expand Up @@ -28,7 +28,6 @@ static function validateDate( $day, $month, $year )
$check = checkdate( $month, $day, $year );
$datetime = mktime( 0, 0, 0, $month, $day, $year );
if ( !$check or
$year < 1970 or
$datetime === false )
{
return eZInputValidator::STATE_INVALID;
Expand All @@ -54,7 +53,6 @@ static function validateDateTime( $day, $month, $year, $hour, $minute, $second =
$check = checkdate( $month, $day, $year );
$datetime = mktime( $hour, $minute, $second, $month, $day, $year );
if ( !$check or
$year < 1970 or
$datetime === false or
eZDateTimeValidator::validateTime( $hour, $minute ) == eZInputValidator::STATE_INVALID )
{
Expand Down

0 comments on commit 2eff97b

Please sign in to comment.