Skip to content
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
merged 15 commits into from
Aug 9, 2019

Conversation

pgomulka
Copy link
Contributor

@pgomulka pgomulka commented Jun 26, 2019

initial work for simplest approach to set start of the week to monday
other could be using using custom locale provider (extending CLDR and overriding startoftheweek method)
relates #42588 an issue with investigation details
relates #41670 bug raised (this won't fix it on its own. joda.parseInto has to be reimplemented
relates #43275 fixed

@pgomulka pgomulka added WIP :Core/Infra/Core Core issues without another label labels Jun 26, 2019
@pgomulka pgomulka self-assigned this Jun 26, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgomulka I think we should pick this back up. I left a few comments.

package org.elasticsearch.common.time;

public class RLocale {
public static final java.util.Locale INS = new java.util.Locale.Builder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put this in DateUtils instead of creating a new class? I also don't know what "INS" is supposed to mean. Maybe ISO8601_LOCALE?

Copy link
Contributor Author

@pgomulka pgomulka Jul 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RLocale.INS was same length as Locale.ROOT - just wanted to quickly see if this passes CI and didn't want to fix all line length violations.
The name obviously ha to be changed - ISO8601_LOCALE sounds good to me.

public class RLocale {
public static final java.util.Locale INS = new java.util.Locale.Builder()
.setLocale(java.util.Locale.ROOT)
.setUnicodeLocaleKeyword("fw", "mon").build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining why this is set to monday, and linking to the appropriate java discussion/code/iso definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@@ -24,6 +23,8 @@
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;

public final class StringUtils {
public static final java.util.Locale WEEK_START_MON = new java.util.Locale.Builder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why another copy? Can we use a single shared locale with this set to monday?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was here because the sql project is not depending on server

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then maybe do put it into it's own class, but in core/libs? It is all jdk based stuff so it should be fine there.

@pgomulka
Copy link
Contributor Author

@rjernst this is still very much a draft, I will certainly rework this properly once I am back from support ramp up.

@pgomulka pgomulka changed the title WIP set start of the week to monday for root locale Set start of the week to Monday for root locale Aug 6, 2019
@pgomulka pgomulka marked this pull request as ready for review August 6, 2019 12:55
@pgomulka
Copy link
Contributor Author

pgomulka commented Aug 7, 2019

@rjernst this is ready for a review now. I wanted also to include Locale.ROOT into forbidden api but there is around 2000usages of that in places which are not related to dates (String.format or toLowerCase methods)

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one request.

* 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 {
Copy link
Member

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).

@pgomulka
Copy link
Contributor Author

pgomulka commented Aug 8, 2019

@elasticmachine run elasticsearch-ci/default-distro

@pgomulka
Copy link
Contributor Author

pgomulka commented Aug 9, 2019

@elasticmachine run elasticsearch-ci/1

@pgomulka pgomulka merged commit 8d1ea86 into elastic:master Aug 9, 2019
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Aug 9, 2019
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
@colings86
Copy link
Contributor

@pgomulka I change the version label here to 7.5 while preparing the 7.4 release notes since the backport is still pending and this is an enhancement. Please let me know if this is wrong

pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Oct 17, 2019
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Oct 17, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants