Skip to content

Commit

Permalink
Use weekyear for consistency
Browse files Browse the repository at this point in the history
Relates: elastic#60044 and elastic#59555 (review)

With the removal of camel case format names,
the format name for `WEEK_YEAR` has been set
to `week_year`, but this is inconsistent with the usage
in other formats related to weekyear e.g.

```
WEEKYEAR_WEEK("weekyear_week"),
WEEKYEAR_WEEK_DAY("weekyear_week_day"),
```

This commit

- replaces the snakecase format `week_year` with `weekyear`
- renames enum constants from `WEEK_YEAR` to `WEEKYEAR` for consistency
  with other constants related to weekyear.
  • Loading branch information
russcam committed Aug 5, 2020
1 parent 393ce41 commit c023825
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ public class DateFormatters {
/*
* Returns a formatter for a four digit weekyear. (YYYY)
*/
private static final DateFormatter WEEK_YEAR = new JavaDateFormatter("week_year",
private static final DateFormatter WEEKYEAR = new JavaDateFormatter("weekyear",
new DateTimeFormatterBuilder().appendValue(WEEK_FIELDS_ROOT.weekBasedYear()).toFormatter(Locale.ROOT)
.withResolverStyle(ResolverStyle.STRICT));

Expand Down Expand Up @@ -1720,9 +1720,9 @@ public class DateFormatters {
return WEEK_DATE_TIME;
} else if (FormatNames.WEEK_DATE_TIME_NO_MILLIS.matches(input)) {
return WEEK_DATE_TIME_NO_MILLIS;
} else if (FormatNames.WEEK_YEAR.matches(input)) {
return WEEK_YEAR;
} else if (FormatNames.WEEK_YEAR_WEEK.matches(input)) {
} else if (FormatNames.WEEKYEAR.matches(input)) {
return WEEKYEAR;
} else if (FormatNames.WEEKYEAR_WEEK.matches(input)) {
return WEEKYEAR_WEEK;
} else if (FormatNames.WEEKYEAR_WEEK_DAY.matches(input)) {
return WEEKYEAR_WEEK_DAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public enum FormatNames {
WEEK_DATE("week_date"),
WEEK_DATE_TIME("week_date_time"),
WEEK_DATE_TIME_NO_MILLIS("week_date_time_no_millis"),
WEEK_YEAR("week_year"),
WEEK_YEAR_WEEK("weekyear_week"),
WEEKYEAR("weekyear"),
WEEKYEAR_WEEK("weekyear_week"),
WEEKYEAR_WEEK_DAY("weekyear_week_day"),
YEAR("year"),
YEAR_MONTH("year_month"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,9 @@ public void testDuellingFormatsValidParsing() {
assertSameDate("2012-1-31", "year_month_day");
assertSameDate("2012-12-1", "year_month_day");

assertSameDate("2018", "week_year");
assertSameDate("1", "week_year");
assertSameDate("2017", "week_year");
assertSameDate("2018", "weekyear");
assertSameDate("1", "weekyear");
assertSameDate("2017", "weekyear");

assertSameDate("2018-W29", "weekyear_week");
assertSameDate("2018-W1", "weekyear_week");
Expand Down Expand Up @@ -778,7 +778,7 @@ public void testSamePrinterOutput() {
assertSamePrinterOutput("week_date", javaDate, jodaDate);
assertSamePrinterOutput("week_date_time", javaDate, jodaDate);
assertSamePrinterOutput("week_date_time_no_millis", javaDate, jodaDate);
assertSamePrinterOutput("week_year", javaDate, jodaDate);
assertSamePrinterOutput("weekyear", javaDate, jodaDate);
assertSamePrinterOutput("weekyear_week", javaDate, jodaDate);
assertSamePrinterOutput("weekyear_week_day", javaDate, jodaDate);
assertSamePrinterOutput("year", javaDate, jodaDate);
Expand Down

0 comments on commit c023825

Please sign in to comment.