Add tests for alternative ways of writing zero offset timezones
According to ISO 8601, a time zone offset of zero, can be stated numerically as "+00:00", "+0000", or "00". The Joda library also seems to allow for "-00:00", "-00" and "-0000". This adds some test to the DateMathParserTests that check that we also conform to this. Closes #21320
This commit is contained in:
parent
f4594d4302
commit
6acbefe3f7
|
@ -82,8 +82,24 @@ public class DateMathParserTests extends ESTestCase {
|
|||
// timezone works within date format
|
||||
assertDateMathEquals("2014-05-30T20:21+02:00", "2014-05-30T18:21:00.000");
|
||||
|
||||
// test alternative ways of writing zero offsets, according to ISO 8601 +00:00, +00, +0000 should work.
|
||||
// joda also seems to allow for -00:00, -00, -0000
|
||||
assertDateMathEquals("2014-05-30T18:21+00:00", "2014-05-30T18:21:00.000");
|
||||
assertDateMathEquals("2014-05-30T18:21+00", "2014-05-30T18:21:00.000");
|
||||
assertDateMathEquals("2014-05-30T18:21+0000", "2014-05-30T18:21:00.000");
|
||||
assertDateMathEquals("2014-05-30T18:21-00:00", "2014-05-30T18:21:00.000");
|
||||
assertDateMathEquals("2014-05-30T18:21-00", "2014-05-30T18:21:00.000");
|
||||
assertDateMathEquals("2014-05-30T18:21-0000", "2014-05-30T18:21:00.000");
|
||||
|
||||
// but also externally
|
||||
assertDateMathEquals("2014-05-30T20:21", "2014-05-30T18:21:00.000", 0, false, DateTimeZone.forID("+02:00"));
|
||||
assertDateMathEquals("2014-05-30T18:21", "2014-05-30T18:21:00.000", 0, false, DateTimeZone.forID("+00:00"));
|
||||
assertDateMathEquals("2014-05-30T18:21", "2014-05-30T18:21:00.000", 0, false, DateTimeZone.forID("+00:00"));
|
||||
assertDateMathEquals("2014-05-30T18:21", "2014-05-30T18:21:00.000", 0, false, DateTimeZone.forID("+00"));
|
||||
assertDateMathEquals("2014-05-30T18:21", "2014-05-30T18:21:00.000", 0, false, DateTimeZone.forID("+0000"));
|
||||
assertDateMathEquals("2014-05-30T18:21", "2014-05-30T18:21:00.000", 0, false, DateTimeZone.forID("-00:00"));
|
||||
assertDateMathEquals("2014-05-30T18:21", "2014-05-30T18:21:00.000", 0, false, DateTimeZone.forID("-00"));
|
||||
assertDateMathEquals("2014-05-30T18:21", "2014-05-30T18:21:00.000", 0, false, DateTimeZone.forID("-0000"));
|
||||
|
||||
// and timezone in the date has priority
|
||||
assertDateMathEquals("2014-05-30T20:21+03:00", "2014-05-30T17:21:00.000", 0, false, DateTimeZone.forID("-08:00"));
|
||||
|
|
Loading…
Reference in New Issue