Skip to content

Commit 6cca07d

Browse files
committed
#25 - empty Date/DateTime means empty string not null.
Thanks to @thomasdv for bugreport!
1 parent bdad4f3 commit 6cca07d

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

Examples/UpdateInvoice.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/php -f
2+
<?php
3+
4+
/**
5+
* AbraFlexi - Example how to create Invoice
6+
*
7+
* @author Vítězslav Dvořák <[email protected]>
8+
* @copyright (G) 2018 Vitex Software
9+
*/
10+
11+
namespace Example\AbraFlexi;
12+
13+
use \AbraFlexi\RO;
14+
use \AbraFlexi\FakturaVydana;
15+
16+
define('EASE_LOGGER', 'syslog|console');
17+
include_once './config.php';
18+
include_once '../vendor/autoload.php';
19+
20+
$invoiceId = 1;
21+
22+
$inv = new FakturaVydana($invoiceId);
23+
$inv->takeData(["stavMailK" => "stavMail.odeslano"]);
24+
$inv->sync();
25+
26+
$inv->addStatusMessage(_('Invoice') . ': ' . $inv->getRecordIdent() . ' ' . $inv->getRecordCode(),
27+
$inv->sync() ? 'success' : 'error' );

src/AbraFlexi/Date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(string $flexidate = 'NOW') {
5151
* @return string
5252
*/
5353
public function __toString() {
54-
return $this->isNull ? null : $this->format(RO::$DateFormat);
54+
return $this->isNull ? '' : $this->format(RO::$DateFormat);
5555
}
5656

5757
}

src/AbraFlexi/DateTime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(string $flexidatetime = 'NOW') {
3434
$format = '';
3535
if (strchr($flexidatetime, '.')) { //NewFormat
3636
$format = RO::$DateTimeFormat;
37-
} elseif ( !empty ($flexidatetime) && ($flexidatetime != 'NOW')) { // Old format
37+
} elseif (!empty($flexidatetime) && ($flexidatetime != 'NOW')) { // Old format
3838
$format = 'Y-m-d\TH:i:s+P';
3939
}
4040
parent::__construct(empty($format) ? null : \DateTime::createFromFormat($format, $flexidatetime)->format(\DateTimeInterface::ATOM));
@@ -46,7 +46,7 @@ public function __construct(string $flexidatetime = 'NOW') {
4646
* @return string
4747
*/
4848
public function __toString() {
49-
return $this->isNull ? null : $this->format(RO::$DateTimeFormat);
49+
return $this->isNull ? '' : $this->format(RO::$DateTimeFormat);
5050
}
5151

5252
}

0 commit comments

Comments
 (0)