Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-414: Allow The Option of T or space for Date time. #415

Merged
merged 1 commit into from
Apr 12, 2017

Conversation

HunterEl
Copy link
Contributor

Please see Github Issue: #414

This PR is to allow for a T or space when providing date times to JSON Schema.

Let me know if there is anything different you would like me to do or if this is not the direction you would like this project to go in.

Thank you!

Copy link
Contributor

@erayd erayd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs unit tests.

@@ -23,7 +23,9 @@ public static function createFromString($string)
$microseconds = $matches[2] ?: '.000000';
$timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';

$dateTime = \DateTime::createFromFormat('Y-m-d\TH:i:s.uP', $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
$dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check strpos($dateAndTime, 'T') === 10) please? That way it won't be tripped up by someone passing a 'T' elsewhere in the string.

Copy link
Contributor

@erayd erayd Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Although that said, I don't think that this is a huge issue, because timezone codes aren't currently allowed, so things like 'PST' will not be an issue at present. So if you'd rather leave it the way it is, that's fine too.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolutely.

@erayd
Copy link
Contributor

erayd commented Apr 12, 2017

Also, could you please change the base for this PR to 6.0.0-dev. I'll backport it for 5.2.x as soon as it's merged.

@erayd erayd mentioned this pull request Apr 12, 2017
@HunterEl HunterEl changed the base branch from master to 6.0.0-dev April 12, 2017 20:37
@HunterEl HunterEl force-pushed the issue-414 branch 3 times, most recently from efd5a9f to a8c849c Compare April 12, 2017 21:19
@HunterEl
Copy link
Contributor Author

@erayd done.

Copy link
Contributor

@erayd erayd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful - thanks :-).

@erayd
Copy link
Contributor

erayd commented Apr 12, 2017

@bighappyface Your turn now :-).

Copy link
Collaborator

@bighappyface bighappyface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@bighappyface bighappyface merged commit 992e1c3 into jsonrainbow:6.0.0-dev Apr 12, 2017
erayd pushed a commit to erayd/json-schema that referenced this pull request Apr 12, 2017
@erayd
Copy link
Contributor

erayd commented Apr 12, 2017

Backported for 5.2.1 in f375f0b.

bighappyface pushed a commit that referenced this pull request May 16, 2017
* Split $objectDefinition into $schema and $properties (#411)

Object validation attempts to use a single variable to store both the
object definition, and its properties. This causes validation to be
incomplete where "properties" is not set, but "additionalProperties" is.

This commit fixes both bugs in issue #353.

* Issue-414: Allow The Option of T or space for Date time. (#415)

* Testcase for minProperties with properties defined (#416)

+ Fix Test

* Tweak phpdocumentor dependency to avoid install conflicts (#421)

* [BUGFIX] Cast empty schema arrays to object (#409)

* Cast root to object

* Use function_exists to allow polyfill compatibility

* Move array->object conversion to SchemaConstraint & SchemaStorage

Fixes issue #408

* fix bug when applying defaults for array items when the schema is for (#405)

all items and add support for minItems when applying defaults

* [BUGFIX] Split "uri" format into "uri" & "uri-reference", fix meta-schema bug (#419)

* Split "uri" format into "uri" and "uri-reference"

* Correct format for id & $ref in draft-03/04 meta-schemas

See json-schema-org/JSON-Schema-Test-Suite#177 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants