Skip to content

Commit 4be9347

Browse files
committed
Add more tests with different types of timezones
1 parent 56f6c40 commit 4be9347

File tree

2 files changed

+98
-2
lines changed

2 files changed

+98
-2
lines changed

ext/date/tests/DateTimeImmutable_createFromInterface.phpt

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ $current = "2014-03-02 16:24:08";
99
$i = DateTimeImmutable::createFromInterface( date_create( $current ) );
1010
var_dump( $i );
1111

12-
DateTimeImmutable::createFromInterface( date_create_immutable( $current ) );
12+
$i = DateTimeImmutable::createFromInterface( date_create_immutable( $current ) );
13+
var_dump( $i );
14+
15+
$current = "2019-12-16 15:06:46 CET";
16+
17+
$i = DateTimeImmutable::createFromInterface( date_create( $current ) );
18+
var_dump( $i );
19+
20+
$i = DateTimeImmutable::createFromInterface( date_create_immutable( $current ) );
21+
var_dump( $i );
22+
23+
$current = "2019-12-16 15:08:20 +0100";
24+
25+
$i = DateTimeImmutable::createFromInterface( date_create( $current ) );
26+
var_dump( $i );
27+
28+
$i = DateTimeImmutable::createFromInterface( date_create_immutable( $current ) );
1329
var_dump( $i );
1430
?>
1531
--EXPECTF--
@@ -29,3 +45,35 @@ object(DateTimeImmutable)#%d (3) {
2945
["timezone"]=>
3046
string(13) "Europe/London"
3147
}
48+
object(DateTimeImmutable)#%d (3) {
49+
["date"]=>
50+
string(26) "2019-12-16 15:06:46.000000"
51+
["timezone_type"]=>
52+
int(2)
53+
["timezone"]=>
54+
string(3) "CET"
55+
}
56+
object(DateTimeImmutable)#%d (3) {
57+
["date"]=>
58+
string(26) "2019-12-16 15:06:46.000000"
59+
["timezone_type"]=>
60+
int(2)
61+
["timezone"]=>
62+
string(3) "CET"
63+
}
64+
object(DateTimeImmutable)#%d (3) {
65+
["date"]=>
66+
string(26) "2019-12-16 15:08:20.000000"
67+
["timezone_type"]=>
68+
int(1)
69+
["timezone"]=>
70+
string(6) "+01:00"
71+
}
72+
object(DateTimeImmutable)#%d (3) {
73+
["date"]=>
74+
string(26) "2019-12-16 15:08:20.000000"
75+
["timezone_type"]=>
76+
int(1)
77+
["timezone"]=>
78+
string(6) "+01:00"
79+
}

ext/date/tests/DateTime_createFromInterface.phpt

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ $current = "2014-03-02 16:24:08";
99
$i = DateTime::createFromInterface( date_create( $current ) );
1010
var_dump( $i );
1111

12-
DateTime::createFromInterface( date_create_immutable( $current ) );
12+
$i = DateTime::createFromInterface( date_create_immutable( $current ) );
13+
var_dump( $i );
14+
15+
$current = "2019-12-16 15:06:46 CET";
16+
17+
$i = DateTime::createFromInterface( date_create( $current ) );
18+
var_dump( $i );
19+
20+
$i = DateTime::createFromInterface( date_create_immutable( $current ) );
21+
var_dump( $i );
22+
23+
$current = "2019-12-16 15:08:20 +0100";
24+
25+
$i = DateTime::createFromInterface( date_create( $current ) );
26+
var_dump( $i );
27+
28+
$i = DateTime::createFromInterface( date_create_immutable( $current ) );
1329
var_dump( $i );
1430
?>
1531
--EXPECTF--
@@ -29,3 +45,35 @@ object(DateTime)#%d (3) {
2945
["timezone"]=>
3046
string(13) "Europe/London"
3147
}
48+
object(DateTime)#%d (3) {
49+
["date"]=>
50+
string(26) "2019-12-16 15:06:46.000000"
51+
["timezone_type"]=>
52+
int(2)
53+
["timezone"]=>
54+
string(3) "CET"
55+
}
56+
object(DateTime)#%d (3) {
57+
["date"]=>
58+
string(26) "2019-12-16 15:06:46.000000"
59+
["timezone_type"]=>
60+
int(2)
61+
["timezone"]=>
62+
string(3) "CET"
63+
}
64+
object(DateTime)#%d (3) {
65+
["date"]=>
66+
string(26) "2019-12-16 15:08:20.000000"
67+
["timezone_type"]=>
68+
int(1)
69+
["timezone"]=>
70+
string(6) "+01:00"
71+
}
72+
object(DateTime)#%d (3) {
73+
["date"]=>
74+
string(26) "2019-12-16 15:08:20.000000"
75+
["timezone_type"]=>
76+
int(1)
77+
["timezone"]=>
78+
string(6) "+01:00"
79+
}

0 commit comments

Comments
 (0)