forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set start of the week to Monday for root locale (elastic#43652)
Introducing a IsoLocal.ROOT constant which should be used instead of java.util.Locale.ROOT in ES when dealing with dates. IsoLocal.ROOT customises start of the week to be Monday instead of Sunday. closes elastic#42588 an issue with investigation details relates elastic#41670 bug raised (this won't fix it on its own. joda.parseInto has to be reimplemented closes elastic#43275 an issue raised by community member change skip reason compile error not orking spi working unit test cleanup change providers for 9+ revert changes IsoLocale cleanup move spi files to server make unit test pass from gradle expermienting with gradle tasks uncomment jar hell check only add settings in buildplugin allign options for locale providers
- Loading branch information
Showing
5 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
...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,47 @@ | ||
--- | ||
setup: | ||
- skip: | ||
version: " - 7.3.99" | ||
reason: "only backported to 7.4 (7x)" | ||
|
||
- 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" } |
41 changes: 41 additions & 0 deletions
41
server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.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,41 @@ | ||
/* | ||
* 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; | ||
|
||
import java.util.Calendar; | ||
import java.util.Locale; | ||
import java.util.spi.CalendarDataProvider; | ||
|
||
public class IsoCalendarDataProvider extends CalendarDataProvider { | ||
|
||
@Override | ||
public int getFirstDayOfWeek(Locale locale) { | ||
return Calendar.MONDAY; | ||
} | ||
|
||
@Override | ||
public int getMinimalDaysInFirstWeek(Locale locale) { | ||
return 4; | ||
} | ||
|
||
@Override | ||
public Locale[] getAvailableLocales() { | ||
return new Locale[]{Locale.ROOT}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
server/src/main/resources/META-INF/services/java.util.spi.CalendarDataProvider
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 @@ | ||
org.elasticsearch.common.time.IsoCalendarDataProvider |
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