Skip to content

Commit 4ab3030

Browse files
committed
Merge origin/main into main
2 parents 9e48791 + aeb9c23 commit 4ab3030

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

src/AbraFlexi/Banka.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ class Banka extends RW {
4040
* @return boolean
4141
*/
4242
public function stahnoutVypisyOnline() {
43-
$this->performRequest('nacteni-vypisu-online.json', 'PUT', 'txt');
43+
try {
44+
$this->performRequest('nacteni-vypisu-online.json', 'PUT', 'txt');
45+
} catch (Exception $exc) {
46+
$this->addStatusMessage('Json response is still plaintext', 'debug');
47+
}
4448
return $this->lastResponseCode == 200;
4549
}
4650

src/AbraFlexi/Date.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,33 @@
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
*
22-
* @param string $flexidate 2017-05-26 or 2017-05-26Z or 2017-05-26+02:00
28+
* @param string $flexidate 2017-05-26 or 2017-05-26Z or 2017-05-26+02:00 or "NOW"
2329
*
2430
* @return \DateTime | false
2531
*/
26-
public function __construct(string $flexidate) {
32+
public function __construct(string $flexidate = 'NOW') {
33+
$this->isNull = empty($flexidate);
34+
$format = '';
2735
if (strstr($flexidate, '+')) {
2836
$format = RO::$DateFormat . 'O';
2937
} elseif (strstr($flexidate, 'Z')) {
3038
$format = RO::$DateFormat . 'Z';
31-
} else {
39+
} elseif ( !empty ($flexidate) && ($flexidate != 'NOW')) {
3240
$format = RO::$DateFormat;
3341
}
34-
parent::__construct(\DateTime::createFromFormat($format, $flexidate)->setTime(0, 0)->format(\DateTimeInterface::ATOM));
42+
if(strstr($flexidate, ':')){ // ?!?!?
43+
$flexidate = substr($flexidate,0, -6);
44+
}
45+
parent::__construct(empty($format) ? null : \DateTime::createFromFormat($format, $flexidate)->setTime(0, 0)->format(\DateTimeInterface::ATOM));
3546
}
3647

3748
/**
@@ -40,7 +51,7 @@ public function __construct(string $flexidate) {
4051
* @return string
4152
*/
4253
public function __toString() {
43-
return $this->format(RO::$DateFormat);
54+
return $this->isNull ? null : $this->format(RO::$DateFormat);
4455
}
4556

4657
}

src/AbraFlexi/DateTime.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,28 @@
1616
*/
1717
class DateTime extends \DateTime {
1818

19+
/**
20+
* Support for Null values
21+
* @var bool
22+
*/
23+
public bool $isNull = false;
24+
1925
/**
2026
* AbraFlexi dateTime to PHP DateTime conversion
2127
*
2228
* @param string $flexidatetime 2017-09-26T10:00:53.755+02:00 or older 2017-05-19T00:00:00+02:00
2329
*
2430
* @return \DateTime | false
2531
*/
26-
public function __construct(string $flexidatetime) {
32+
public function __construct(string $flexidatetime = 'NOW') {
33+
$this->isNull = empty($flexidatetime);
34+
$format = '';
2735
if (strchr($flexidatetime, '.')) { //NewFormat
2836
$format = RO::$DateTimeFormat;
29-
} else { // Old format
37+
} elseif ( !empty ($flexidatetime) && ($flexidatetime != 'NOW')) { // Old format
3038
$format = 'Y-m-d\TH:i:s+P';
3139
}
32-
parent::__construct(\DateTime::createFromFormat($format, $flexidatetime)->format(\DateTimeInterface::ATOM));
40+
parent::__construct(empty($format) ? null : \DateTime::createFromFormat($format, $flexidatetime)->format(\DateTimeInterface::ATOM));
3341
}
3442

3543
/**
@@ -38,7 +46,7 @@ public function __construct(string $flexidatetime) {
3846
* @return string
3947
*/
4048
public function __toString() {
41-
return $this->format(RO::$DateTimeFormat);
49+
return $this->isNull ? null : $this->format(RO::$DateTimeFormat);
4250
}
4351

4452
}

0 commit comments

Comments
 (0)