-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Set start of the week to Monday for root locale #43652
Merged
+343
−207
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9ab7c92
set start of the week to monday for root locale
pgomulka 646bc7d
make more code use changed root
pgomulka ead2668
dummy fix for checkstyle
pgomulka 029c015
fix checkstyle
pgomulka 5249b4c
fix root
pgomulka cea5410
Merge branch 'master' into fix/start_of_week
pgomulka e5084f5
test fix
pgomulka f8a9279
class rename and move to libs/cli/core
pgomulka 95ab0c0
Merge branch 'master' into fix/start_of_week
pgomulka 35dd579
yml test
pgomulka 47b3e5b
typo
pgomulka c99048e
unit test
pgomulka 9a80fc2
rename the locale class
pgomulka bd05fe5
Merge branch 'master' into fix/start_of_week
pgomulka e1218ea
skip the yml teste until backported
pgomulka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
libs/core/src/main/java/org/elasticsearch/common/time/Locale.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.common.time; | ||
|
||
/** | ||
* Locale constants to be used across elasticsearch code base. | ||
* java.util.Locale.ROOT should not be used as it defaults start of the week incorrectly to Sunday. | ||
*/ | ||
public class Locale { | ||
/** | ||
* We want to use Locale.ROOT but with a start of the week as defined in ISO8601 to be compatible with the behaviour in joda-time | ||
* https://github.com/elastic/elasticsearch/issues/42588 | ||
* @see java.time.temporal.WeekFields#of(java.util.Locale) | ||
*/ | ||
public static final java.util.Locale ISO8601 = new java.util.Locale.Builder() | ||
.setLocale(java.util.Locale.ROOT) | ||
.setUnicodeLocaleKeyword("fw", "mon").build(); | ||
} |
43 changes: 43 additions & 0 deletions
43
...src/main/resources/rest-api-spec/test/search.aggregation/310_date_agg_per_day_of_week.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
properties: | ||
date: | ||
type: date | ||
|
||
- do: | ||
index: | ||
index: test | ||
id: 1 | ||
body: { "date": "2009-11-15T14:12:12" } | ||
|
||
- do: | ||
indices.refresh: | ||
index: [test] | ||
|
||
--- | ||
# The inserted document has a field date=2009-11-15T14:12:12 which is Sunday. | ||
# When aggregating per day of the week this should be considered as last day of the week (7) | ||
# and this value should be used in 'key_as_string' | ||
"Date aggregartion per day of week": | ||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: test | ||
body: | ||
aggregations: | ||
test: | ||
"date_histogram": { | ||
"field": "date", | ||
"calendar_interval": "day", | ||
"format": "e", | ||
"offset": 0 | ||
} | ||
|
||
- match: {hits.total: 1} | ||
- length: { aggregations.test.buckets: 1 } | ||
- match: { aggregations.test.buckets.0.key_as_string: "7" } |
409 changes: 216 additions & 193 deletions
409
server/src/main/java/org/elasticsearch/common/time/DateFormatters.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Can we use a different class name that does not collide with java's Locale, so that we don't need to deal with fully qualified class names? Perhaps IsoLocale (we should also make this class not constructable).