Skip to content

Commit 9f498e4

Browse files
committed
style(datefield, datetimefield: use constant
1 parent 6328fc6 commit 9f498e4

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

inc/field/datefield.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
class DateField extends DatetimeField
4343
{
4444
const DATE_FORMAT = 'Y-m-d';
45+
const DATE_ZERO = '0000-00-00';
4546

4647
public function getRenderedHtml($domain, $canEdit = true): string {
4748
if (!$canEdit) {
@@ -77,7 +78,7 @@ public static function getName(): string {
7778
*/
7879
protected function getDateFromValue(string $value) {
7980
if (empty($value)) {
80-
$value = '0000-00-00';
81+
$value = self::DATE_ZERO;
8182
}
8283
$datetime = DateTime::createFromFormat(self::DATE_FORMAT, $value);
8384
if ($datetime !== false) {

inc/field/datetimefield.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class DatetimeField extends PluginFormcreatorAbstractField
4646
protected $fields = null;
4747

4848
const DATE_FORMAT = 'Y-m-d H:i:s';
49+
const DATE_ZERO = '0000-00-00 00:00:00';
4950

5051
public function isPrerequisites(): bool {
5152
return true;
@@ -151,7 +152,7 @@ public static function canRequire(): bool {
151152
*/
152153
protected function getDateFromValue(string $value) {
153154
if (empty($value)) {
154-
$value = '0000-00-00 00:00:00';
155+
$value = self::DATE_ZERO;
155156
}
156157
return DateTime::createFromFormat(self::DATE_FORMAT, $value);
157158
}

0 commit comments

Comments
 (0)