@@ -54,6 +54,36 @@ public function testFromDateTime(): void
5454 }
5555
5656
57+ /**
58+ */
59+ public function testSubSeconds (): void
60+ {
61+ // Strip sub-second trailing zero's and make sure the decimal sign is removed
62+ $ dateTimeValue = DateTimeValue::fromString ('2001-10-26T21:32:52.00 ' );
63+ $ this ->assertEquals ('2001-10-26T21:32:52 ' , $ dateTimeValue ->getValue ());
64+
65+ // Strip sub-second trailing zero's
66+ $ dateTimeValue = DateTimeValue::fromString ('2001-10-26T21:32:52.12300 ' );
67+ $ this ->assertEquals ('2001-10-26T21:32:52.123 ' , $ dateTimeValue ->getValue ());
68+
69+ // Strip sub-seconds over microsecond precision
70+ $ dateTimeValue = DateTimeValue::fromString ('2001-10-26T21:32:52.1234567 ' );
71+ $ this ->assertEquals ('2001-10-26T21:32:52.123456 ' , $ dateTimeValue ->getValue ());
72+
73+ // Strip sub-second trailing zero's and make sure the decimal sign is removed
74+ $ dateTimeValue = DateTimeValue::fromString ('2001-10-26T21:32:52.00Z ' );
75+ $ this ->assertEquals ('2001-10-26T21:32:52Z ' , $ dateTimeValue ->getValue ());
76+
77+ // Strip sub-seconds over microsecond precision with timezone
78+ $ dateTimeValue = DateTimeValue::fromString ('2001-10-26T21:32:52.1234567+01:00 ' );
79+ $ this ->assertEquals ('2001-10-26T21:32:52.123456+01:00 ' , $ dateTimeValue ->getValue ());
80+
81+ // Strip sub-seconds over microsecond precision with timezone Zulu
82+ $ dateTimeValue = DateTimeValue::fromString ('2001-10-26T21:32:52.1234567Z ' );
83+ $ this ->assertEquals ('2001-10-26T21:32:52.123456Z ' , $ dateTimeValue ->getValue ());
84+ }
85+
86+
5787 /**
5888 * @return array<string, array{0: true, 1: string}>
5989 */
0 commit comments