-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Changes from 7 commits
9ab7c92
646bc7d
ead2668
029c015
5249b4c
cea5410
e5084f5
f8a9279
95ab0c0
35dd579
47b3e5b
c99048e
9a80fc2
bd05fe5
e1218ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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; | ||
|
||
public class RLocale { | ||
public static final java.util.Locale INS = new java.util.Locale.Builder() | ||
.setLocale(java.util.Locale.ROOT) | ||
.setUnicodeLocaleKeyword("fw", "mon").build(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeFormatterBuilder; | ||
import java.util.Locale; | ||
import java.util.Objects; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
|
@@ -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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was here because the sql project is not depending on server There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
.setLocale(java.util.Locale.ROOT).setUnicodeLocaleKeyword("fw", "mon").build(); | ||
|
||
public static final String EMPTY = ""; | ||
|
||
|
@@ -38,7 +39,7 @@ public final class StringUtils { | |
.appendValue(SECOND_OF_MINUTE, 2) | ||
.appendFraction(MILLI_OF_SECOND, 3, 3, true) | ||
.appendOffsetId() | ||
.toFormatter(Locale.ROOT); | ||
.toFormatter(WEEK_START_MON); | ||
|
||
public static final DateTimeFormatter ISO_TIME_WITH_MILLIS = new DateTimeFormatterBuilder() | ||
.parseCaseInsensitive() | ||
|
@@ -49,7 +50,7 @@ public final class StringUtils { | |
.appendValue(SECOND_OF_MINUTE, 2) | ||
.appendFraction(MILLI_OF_SECOND, 3, 3, true) | ||
.appendOffsetId() | ||
.toFormatter(Locale.ROOT); | ||
.toFormatter(WEEK_START_MON); | ||
|
||
private static final int SECONDS_PER_MINUTE = 60; | ||
private static final int SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60; | ||
|
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 put this in DateUtils instead of creating a new class? I also don't know what "INS" is supposed to mean. Maybe ISO8601_LOCALE?
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.
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.