tests: writer options
[awesomized/ext-ion] / tests / Timestamp.phpt
index 6b263ecbb522716a0ca2fb6a40092e69c4b9e556..e92905bbfd7229c5f47187cf7260359f82a96fd3 100644 (file)
@@ -14,11 +14,14 @@ try {
 } catch (Throwable) {
        echo "caught empty\n";
 }
-$full = "2021-12-07T14:08:51+00:00";
+$full = "2021-12-07T14:08:51.123456+00:00";
 var_dump($t=new Timestamp(Timestamp\Precision::Day, datetime:$full),(string)$t);
 var_dump($t=new Timestamp(Timestamp\Precision::Day->value, datetime:$full),(string)$t);
 var_dump($t=new Timestamp(Timestamp\Precision::Min, datetime:"2020-10-01"),(string)$t);
+$t->setTimezone(new DateTimeZone("Europe/Helsinki"));
+var_dump((string) $t);
 var_dump($t=new Timestamp(Timestamp\Precision::Day, "!Y-m", "2000-10"),(string)$t);
+var_dump(ion\unserialize(ion\serialize(clone new ion\Timestamp(ion\Timestamp\Precision::Sec, DateTime::RFC3339, "1971-02-03T04:05:06Z"))));
 ?>
 DONE
 --EXPECTF--
@@ -30,7 +33,7 @@ object(ion\Timestamp)#%d (5) {
   ["format"]=>
   string(7) "Y-m-d\T"
   ["date"]=>
-  string(26) "2021-12-07 14:08:51.000000"
+  string(26) "2021-12-07 14:08:51.123456"
   ["timezone_type"]=>
   int(1)
   ["timezone"]=>
@@ -43,7 +46,7 @@ object(ion\Timestamp)#%d (5) {
   ["format"]=>
   string(7) "Y-m-d\T"
   ["date"]=>
-  string(26) "2021-12-07 14:08:51.000000"
+  string(26) "2021-12-07 14:08:51.123456"
   ["timezone_type"]=>
   int(1)
   ["timezone"]=>
@@ -54,7 +57,7 @@ object(ion\Timestamp)#%d (5) {
   ["precision"]=>
   int(23)
   ["format"]=>
-  string(11) "Y-m-d\TH:iP"
+  string(10) "Y-m-d\TH:i"
   ["date"]=>
   string(26) "2020-10-01 00:00:00.000000"
   ["timezone_type"]=>
@@ -62,7 +65,8 @@ object(ion\Timestamp)#%d (5) {
   ["timezone"]=>
   string(3) "CET"
 }
-string(22) "2020-10-01T00:00+02:00"
+string(16) "2020-10-01T00:00"
+string(16) "2020-10-01T01:00"
 object(ion\Timestamp)#%d (5) {
   ["precision"]=>
   int(7)
@@ -76,4 +80,12 @@ object(ion\Timestamp)#%d (5) {
   string(3) "CET"
 }
 string(11) "2000-10-01T"
+object(ion\Timestamp)#%d (3) {
+  ["precision"]=>
+  int(55)
+  ["format"]=>
+  string(12) "Y-m-d\TH:i:s"
+  ["date"]=>
+  string(26) "1971-02-03 04:05:06.000000"
+}
 DONE