-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Make timezone in "strict_date_time" format optional #16701
Conversation
Signed-off-by: Peter Alfonsi <[email protected]>
Signed-off-by: Peter Alfonsi <[email protected]>
@@ -741,7 +743,9 @@ public class DateFormatters { | |||
.toFormatter(Locale.ROOT) | |||
.withResolverStyle(ResolverStyle.STRICT), | |||
new DateTimeFormatterBuilder().append(STRICT_DATE_FORMATTER) | |||
.optionalStart() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the reasons it is called STRICT_DATE_TIME
is because all components are required, changing that would lead to surprising results. We have a large number of relaxed formats like STRICT_DATE_OPTIONAL_TIME, STRICT_DATE_OPTIONAL_TIME_NANOS, those are explicit on optionality of some components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that we probably don't want to change the definition of what STRICT_DATE_TIME
means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. In this case I'll close this PR and recommend that the person who created the original issue changes their mapping to use a different format.
❌ Gradle check result for d54ff3c: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
I wanted to follow up on @peteralfonsi comment (and thanks @peteralfonsi for the PR!). I know that I'm collecting different flavours of ISO8601 in this thread: https://bsky.app/profile/dep4b.bsky.social/post/3lbadp742pk26 ;-) |
Description
Changes
"strict_date_time"
format to make the timezone optional. For example,2024-06-01T13:38:18.280
was not previously allowed, only2024-06-01T13:38:18.280Z
or2024-06-01T13:38:18.280Z+00:00
. If there's no timezone, it defaults to UTC. This is useful as Python'sisoformat()
can output times like this, and they are ISO 8601 compliant.Adds UT. Also tested manually with the mapping:
and indexing two documents, one with timestamp "2023-01-01T14:14:14Z" and one with "2023-01-01T14:14:14". In the existing code, the second one failed with
RequestError(400, 'mapper_parsing_exception', "failed to parse field [timestamp] of type [date] in document with id '2'. Preview of field's value: '2023-02-02T14:14:14'")
.After this change, both are accepted.
Related Issues
Resolves #16673
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.