-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Scripting: Rework joda time backcompat #33486
Changes from 14 commits
f815009
8260827
56f1f1e
9035788
d876b3d
f3ec719
19019e7
92a227c
8cc0a3a
3930cf6
bd83968
11e03c7
eab341a
f105096
03a28dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
import org.elasticsearch.common.text.Text; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; | ||
import org.elasticsearch.script.JodaCompatibleZonedDateTime; | ||
import org.joda.time.DateTimeZone; | ||
import org.joda.time.ReadableInstant; | ||
|
||
|
@@ -680,6 +681,15 @@ public final <K, V> void writeMap(final Map<K, V> map, final Writer<K> keyWriter | |
o.writeString(zonedDateTime.getZone().getId()); | ||
o.writeLong(zonedDateTime.toInstant().toEpochMilli()); | ||
}); | ||
writers.put(JodaCompatibleZonedDateTime.class, (o, v) -> { | ||
// write the joda compatibility datetime as joda datetime | ||
o.writeByte((byte) 13); | ||
final JodaCompatibleZonedDateTime zonedDateTime = (JodaCompatibleZonedDateTime) v; | ||
String zoneId = zonedDateTime.getZonedDateTime().getZone().getId(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops. This was because the zoneId used by joda doesn't appear to always be the same as java time. Joda does not know how to parse "Z". I'll add special casing for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed f105096 |
||
// joda does not understand "Z" for utc, so we must special case | ||
o.writeString(zoneId.equals("Z") ? DateTimeZone.UTC.getID() : zoneId); | ||
o.writeLong(zonedDateTime.toInstant().toEpochMilli()); | ||
}); | ||
WRITERS = Collections.unmodifiableMap(writers); | ||
} | ||
|
||
|
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.
where is this one coming from?
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.
ignore this, misread it as being something for BWC, but it's a new method