Skip to content

Commit d5a2a15

Browse files
committed
Support for Null added
1 parent d9c4db5 commit d5a2a15

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/AbraFlexi/Date.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
*/
1717
class Date extends \DateTime {
1818

19+
/**
20+
* Support for Null values
21+
* @var bool
22+
*/
23+
public bool $isNull = false;
24+
1925
/**
2026
* AbraFlexi date to PHP DateTime conversion
2127
*
@@ -24,6 +30,7 @@ class Date extends \DateTime {
2430
* @return \DateTime | false
2531
*/
2632
public function __construct(string $flexidate = 'NOW') {
33+
$this->isNull = is_null($flexidate);
2734
$format = '';
2835
if (strstr($flexidate, '+')) {
2936
$format = RO::$DateFormat . 'O';
@@ -41,7 +48,7 @@ public function __construct(string $flexidate = 'NOW') {
4148
* @return string
4249
*/
4350
public function __toString() {
44-
return $this->format(RO::$DateFormat);
51+
return $this->isNull ? null : $this->format(RO::$DateFormat);
4552
}
4653

4754
}

0 commit comments

Comments
 (0)