-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[CI] Fix year of week formatting when using joda time #66914
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
Conversation
Pinging @elastic/es-core-infra (Team:Core/Infra) |
I'm not sure this is the correct fix. Why is |
OK, having read https://www.alexcorrigan.co.uk/blog/20191231-0644-javas-week-based-year-datetimeformatter/ I understand what the issue is - |
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.
This test is based on joda format (was possibly missed when migrating) and Y meant year of era in joda.
It should be changed to uuuu when using java.time
in week based calendar 01-03.01.2021 are still in 2020. The first week of 2021 starts on Monday 4th. This is because it requires first week to contain minimum 4 days in new year. Also Monday is the first day fo the week per ISO rule. This is all because YYYY (week based year) was used instead of yyyy (year of era) or uuuu (year) |
If the intention is to use "year-of-era", I can change the date-math-expression to use @@ -115,7 +115,7 @@ public class DateMathExpressionResolverTests extends ESTestCase {
public void testExpression_MixedArray() throws Exception {
List<String> result = expressionResolver.resolve(context, Arrays.asList(
- "name1", "<.marvel-{now/d}>", "name2", "<.logstash-{now/M{YYYY.MM}}>"
+ "name1", "<.marvel-{now/d}>", "name2", "<.logstash-{now/M{yyyy.MM}}>"
));
assertThat(result.size(), equalTo(4));
assertThat(result.get(0), equalTo("name1")); Alternatively, we can change both date-math-expression and the assertion to use simply "year", i.e. |
@ywangd edit - you are right. it should be uuuu in the date math, and yyyy in assertion as the assertion is still using joda. We should migrate this test in another PR |
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.
LGTM, thanks!
…#66914) This PR fixes the test failure by ensuring consistent datetime formatting between java DateTimeFormatter and joda time.
…#66914) This PR fixes the test failure by ensuring consistent datetime formatting between java DateTimeFormatter and joda time.
…#66932) This PR fixes the test failure by ensuring consistent datetime formatting between java DateTimeFormatter and joda time. Co-authored-by: Yang Wang <[email protected]>
…#66914) This PR fixes the test failure by ensuring consistent datetime formatting between java DateTimeFormatter and joda time.
Based on the joda-time documentation, the symbol for "year of the week" is
x
as opposed toY
(used by java's DateTimeFormatter). This PR fixes the test code to use the correct date formatting symbol.Resolves: #66907