tests++
[awesomized/ext-ion] / tests / Timestamp.phpt
1 --TEST--
2 ion\Timestamp
3 --EXTENSIONS--
4 ion
5 --INI--
6 date.timezone=CET
7 --FILE--
8 TEST
9 <?php
10 use ion\Timestamp;
11
12 try {
13 var_dump(new Timestamp);
14 } catch (Throwable) {
15 echo "caught empty\n";
16 }
17 $full = "2021-12-07T14:08:51+00:00";
18 var_dump($t=new Timestamp(Timestamp\Precision::Day, datetime:$full),(string)$t);
19 var_dump($t=new Timestamp(Timestamp\Precision::Day->value, datetime:$full),(string)$t);
20 var_dump($t=new Timestamp(Timestamp\Precision::Min, datetime:"2020-10-01"),(string)$t);
21 var_dump($t=new Timestamp(Timestamp\Precision::Day, "!Y-m", "2000-10"),(string)$t);
22 ?>
23 DONE
24 --EXPECTF--
25 TEST
26 caught empty
27 object(ion\Timestamp)#%d (5) {
28 ["precision"]=>
29 int(7)
30 ["format"]=>
31 string(7) "Y-m-d\T"
32 ["date"]=>
33 string(26) "2021-12-07 14:08:51.000000"
34 ["timezone_type"]=>
35 int(1)
36 ["timezone"]=>
37 string(6) "+00:00"
38 }
39 string(11) "2021-12-07T"
40 object(ion\Timestamp)#%d (5) {
41 ["precision"]=>
42 int(7)
43 ["format"]=>
44 string(7) "Y-m-d\T"
45 ["date"]=>
46 string(26) "2021-12-07 14:08:51.000000"
47 ["timezone_type"]=>
48 int(1)
49 ["timezone"]=>
50 string(6) "+00:00"
51 }
52 string(11) "2021-12-07T"
53 object(ion\Timestamp)#%d (5) {
54 ["precision"]=>
55 int(23)
56 ["format"]=>
57 string(11) "Y-m-d\TH:iP"
58 ["date"]=>
59 string(26) "2020-10-01 00:00:00.000000"
60 ["timezone_type"]=>
61 int(3)
62 ["timezone"]=>
63 string(3) "CET"
64 }
65 string(22) "2020-10-01T00:00+02:00"
66 object(ion\Timestamp)#%d (5) {
67 ["precision"]=>
68 int(7)
69 ["format"]=>
70 string(7) "Y-m-d\T"
71 ["date"]=>
72 string(26) "2000-10-01 00:00:00.000000"
73 ["timezone_type"]=>
74 int(3)
75 ["timezone"]=>
76 string(3) "CET"
77 }
78 string(11) "2000-10-01T"
79 DONE