When the underlying field has a null value and we call the method getDateTimeObject to obtain the DateTime? object, we get a new DateTime? object with the current time.
And this is because the constructor of the DateTime? automatically assigns the current date if a null parameter is passed on.
To me the solution should be: if the underlying field has a null value and the getDateTimeObject is called, the return value should also be a null value.
Before:
public function getDateTimeObject($dateFieldName)
{
$type = $this->getTable()->getTypeOf($dateFieldName);
if ($type == 'date'
$type == 'timestamp' | $type == 'datetime')
{
return new DateTime?($this->get($dateFieldName));
}
After
public function getDateTimeObject($dateFieldName)
{
$type = $this->getTable()->getTypeOf($dateFieldName);
if ($type == 'date' $type == 'timestamp' | $type == 'datetime')
{
$d = $this->get($dateFieldName);
return isset(d) ? new DateTime?(d) : null;
}
Download in other formats:
| |