We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 37810e9 commit 2f0f47aCopy full SHA for 2f0f47a
2 files changed
src/JsonSchema/Constraints/FormatConstraint.php
@@ -138,7 +138,7 @@ protected function validateDateTime($datetime, $format)
138
// which will fail the above string comparison because the passed
139
// $datetime may be '2000-05-01T12:12:12.123Z' but format() will return
140
// '2000-05-01T12:12:12.123000Z'
141
- if ((strpos('u', $format) !== -1) && (intval($dt->format('u')) > 0)) {
+ if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
142
return true;
143
}
144
tests/JsonSchema/Tests/Constraints/FormatTest.php
@@ -81,6 +81,10 @@ public function getValidFormats()
81
array('2000-05-01T12:12:12+01:00', 'date-time'),
82
array('2000-05-01T12:12:12.123456Z', 'date-time'),
83
array('2000-05-01T12:12:12.123Z', 'date-time'),
84
+ array('2000-05-01T12:12:12.123000Z', 'date-time'),
85
+ array('2000-05-01T12:12:12.0Z', 'date-time'),
86
+ array('2000-05-01T12:12:12.000Z', 'date-time'),
87
+ array('2000-05-01T12:12:12.000000Z', 'date-time'),
88
89
array('0', 'utc-millisec'),
90
@@ -140,6 +144,7 @@ public function getInvalidFormats()
array('1999-1-11T00:00:00Z', 'date-time'),
145
array('1999-01-11T00:00:00+100', 'date-time'),
146
array('1999-01-11T00:00:00+1:00', 'date-time'),
147
+ array('1999.000Z-01-11T00:00:00+1:00', 'date-time'),
148
149
array('-1', 'utc-millisec'),
150
array(PHP_INT_MAX, 'utc-millisec'),
0 commit comments