ezsystems/ezpublish-kernel — pull request #1070 by glye (2014-11-06 14:26:01+00:00)
Title: Fix EZP-23573: ez_is_field_empty does not work for a "date and time" fie...

...ld

Ensures that zero DateTimes are interpreted as null, so they are recognized as empty.

https://jira.ez.no/browse/EZP-23573

As I understand it, an empty DateAndTime is stored in the DB as a zero, which when loaded is initialised with a zero DateTime, and that doesn't match the null which DateAndTime/Type::getEmptyValue() produces.

Alternative solution 1: Change DateAndTime/Value::fromString() and fromTimestamp() so that if the argument is zero, return new static() instead of an instance based on the timestamp.

Alternative solution 2: Reimplement DateAndTime/Type::isEmptyValue( SPIValue $value ) and change it from
return $value === null || $value == $this->getEmptyValue();
to
return $value === null || $value == $this->getEmptyValue() || $value == new Value( new DateTime( '@0' ) );

Anyway, the consequence is that it's not possible to distinguish between "1.1.1970 00:00:00" and "empty", but that's the case now, too.