fix(core): deal with unqualified date times in local offsets #553
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new option to the
JSONGenerator
andJSONPopulator
classes (and theSerializer
) calledstrictQualifiedDateTimes
. This allows client applications to drop support for unqualified, and ambiguous dates/datetimes.This solves #552 in a backward-compatible way by not-allowing dates and date-times that don't have an offset. This also has the side-effect of making the
utcOffset
parameter only relevant to serialization; i.e. it becomes a rendering option. We always trust the offset provided whenstrictQualifiedDateTimes
istrue
When
strictQualifiedDateTimes
istrue
, only the following date-time formats are accepted.YYYY-MM-DDTHH:mm:ssZ
YYYY-MM-DDTHH:mm:ss.SZ
YYYY-MM-DDTHH:mm:ss.SSZ
YYYY-MM-DDTHH:mm:ss.SSSZ
YYYY-MM-DDTHH:mm:ss+HH:mm
YYYY-MM-DDTHH:mm:ss.S+HH:mm
YYYY-MM-DDTHH:mm:ss.SS+HH:mm
YYYY-MM-DDTHH:mm:ss.SSS+HH:mm
YYYY-MM-DDTHH:mm:ss-HH:mm
YYYY-MM-DDTHH:mm:ss.S-HH:mm
YYYY-MM-DDTHH:mm:ss.SS-HH:mm
YYYY-MM-DDTHH:mm:ss.SSS-HH:mm
There are lots of formats that are no-longer accepted, for example (see the test for the full set):
YYYY-MM-DD
YYYY-MM-DDTHH:mm:ss
YYYY-MM-DDTHH:mm:ss.S
YYYY-MM-DDTHH:mm:ss.SS
YYYY-MM-DDTHH:mm:ss.SSS
Changes
strictQualifiedDateTimes
toJSONGenerator
andJSONPopulator
.Flags
strictQualifiedDateTimes
flag, this has the effect of removing support dates (without explicit times).Author Checklist
--signoff
option of git commit.main
fromfork:branchname