Skip to content

Commit 2f1c707

Browse files
committed
Fixed work with Date/Timezone
1 parent 3848cae commit 2f1c707

File tree

5 files changed

+75
-8
lines changed

5 files changed

+75
-8
lines changed

debian/changelog

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
php-spojenet-abraflexi (2.15) UNRELEASED; urgency=medium
1+
php-spojenet-abraflexi (2.16) UNRELEASED; urgency=medium
22

33
[ Vítězslav Dvořák ]
44
* ease-core based
@@ -36,8 +36,9 @@ php-spojenet-abraflexi (2.15) UNRELEASED; urgency=medium
3636
* v2.13 release
3737
* v2.14 release
3838
* Relation class introduced
39+
* Relations recovered
3940

40-
-- vitex <[email protected]> Tue, 05 Oct 2021 11:17:03 +0200
41+
-- vitex <[email protected]> Sun, 17 Oct 2021 15:19:51 +0200
4142

4243
flexipeehp (1.12) experimental; urgency=medium
4344

debian/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Library for easy interaction with czech accounting system AbraFlexi.",
44
"homepage": "https://github.com/Spoje-NET/php-abraflexi",
55
"license": "GPL-2.0+",
6-
"version": "2.15",
6+
"version": "2.16",
77
"type": "library",
88
"authors": [
99
{

src/AbraFlexi/Date.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ public function __construct(string $flexidate = 'NOW') {
3333
$this->isNull = empty($flexidate);
3434
$format = '';
3535
if (strstr($flexidate, '+')) {
36-
$format = RO::$DateFormat . 'O';
36+
$format = RO::$DateFormat . 'T';
3737
} elseif (strstr($flexidate, 'Z')) {
3838
$format = RO::$DateFormat . 'Z';
39-
} elseif ( !empty ($flexidate) && ($flexidate != 'NOW')) {
39+
} elseif (!empty($flexidate) && ($flexidate != 'NOW')) {
4040
$format = RO::$DateFormat;
4141
}
42-
if(strstr($flexidate, ':')){ // ?!?!?
43-
$flexidate = substr($flexidate,0, -6);
44-
}
4542
parent::__construct(empty($format) ? null : \DateTime::createFromFormat($format, $flexidate)->setTime(0, 0)->format(\DateTimeInterface::ATOM));
4643
}
4744

testing/src/AbraFlexi/DateTest.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Test\AbraFlexi;
4+
5+
use AbraFlexi\Date;
6+
7+
/**
8+
* Generated by PHPUnit_SkeletonGenerator on 2021-10-17 at 16:07:28.
9+
*/
10+
class DateTest extends \PHPUnit\Framework\TestCase {
11+
12+
/**
13+
* @var Date
14+
*/
15+
protected $object;
16+
17+
/**
18+
* Sets up the fixture, for example, opens a network connection.
19+
* This method is called before a test is executed.
20+
*/
21+
protected function setUp(): void {
22+
$this->object = new Date();
23+
}
24+
25+
/**
26+
* Tears down the fixture, for example, closes a network connection.
27+
* This method is called after a test is executed.
28+
*/
29+
protected function tearDown(): void {
30+
31+
}
32+
33+
/**
34+
* Test Constructor
35+
*
36+
* @covers AbraFlexi\Date::__construct
37+
*/
38+
public function testConstructor() {
39+
$classname = get_class($this->object);
40+
41+
// Get mock, without the constructor being called
42+
$mock = $this->getMockBuilder($classname)
43+
->disableOriginalConstructor()
44+
->getMockForAbstractClass();
45+
46+
$mock->__construct('');
47+
$this->assertTrue($mock->isNull);
48+
49+
$mock->__construct('NOW');
50+
$this->assertFalse($mock->isNull);
51+
52+
$mock->__construct('2021-10-16');
53+
54+
$mock->__construct('2021-10-16+02:00');
55+
56+
$mock->__construct('2021-10-16Z');
57+
58+
}
59+
60+
61+
62+
/**
63+
* @covers AbraFlexi\Date::__toString
64+
*/
65+
public function test__toString() {
66+
$this->assertEquals(date('Y-m-d'), $this->object->__toString());
67+
}
68+
69+
}

0 commit comments

Comments
 (0)