Skip to content

Commit

Permalink
The <dateTime.iso8601> accepts zone in +HH00 format (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
spagr authored and milo committed Sep 6, 2017
1 parent dc4cabb commit ae18f8c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/XmlRpc/xml-rpc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<choice>
<data type="dateTime" />
<data type="string">
<param name="pattern">[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z?</param>
<param name="pattern">[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}([+-]\d\d:?\d\d|Z)?</param>
</data>
</choice>
</element>
Expand Down
7 changes: 7 additions & 0 deletions tests/XmlRpc/Coder.dateTime.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ $doc->loadXML($xml);
$var = $coder->decodeValueNode($doc->documentElement);
Assert::equal([
DateTime::createFromFormat('Y-m-d H:i:s P', '2000-01-20 12:30:00 +02:30'),
DateTime::createFromFormat('Y-m-d H:i:s P', '2000-01-20 12:30:00 -02:30'),
DateTime::createFromFormat('Y-m-d H:i:s', '2000-01-20 12:30:00'),

DateTime::createFromFormat('Y-m-d H:i:s P', '2000-01-20 12:30:00 +02:30'),
DateTime::createFromFormat('Y-m-d H:i:s P', '2000-01-20 12:30:00 -02:30'),
DateTime::createFromFormat('Y-m-d H:i:s', '2000-01-20 12:30:00'),

DateTime::createFromFormat('Y-m-d H:i:s P', '2000-01-20 12:30:00 Z'),

DateTime::createFromFormat('Y-m-d H:i:s P', '2000-01-20 12:30:00+0200'),
DateTime::createFromFormat('Y-m-d H:i:s P', '2000-01-20 12:30:00-0200'),
], $var);
17 changes: 16 additions & 1 deletion tests/XmlRpc/files/Coder.dateTime.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,33 @@
<value>
<dateTime.iso8601>2000-01-20T12:30:00+02:30</dateTime.iso8601>
</value>
<value>
<dateTime.iso8601>2000-01-20T12:30:00-02:30</dateTime.iso8601>
</value>
<value>
<dateTime.iso8601>2000-01-20T12:30:00</dateTime.iso8601>
</value>

<value>
<dateTime.iso8601>20000120T12:30:00+02:30</dateTime.iso8601>
</value>
<value>
<dateTime.iso8601>20000120T12:30:00</dateTime.iso8601>
<dateTime.iso8601>20000120T12:30:00-02:30</dateTime.iso8601>
</value>
<value>
<dateTime.iso8601>20000120T12:30:00</dateTime.iso8601>
</value>

<value>
<dateTime.iso8601>20000120T12:30:00Z</dateTime.iso8601>
</value>

<value>
<dateTime.iso8601>20000120T12:30:00+0200</dateTime.iso8601>
</value>
<value>
<dateTime.iso8601>20000120T12:30:00-0200</dateTime.iso8601>
</value>
</data>
</array>
</value>

0 comments on commit ae18f8c

Please sign in to comment.