Skip to content

Commit

Permalink
disable year-of-era relaxation to fail tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pgomulka committed Sep 30, 2019
1 parent 050ec42 commit 4ebd7b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Function<String, ZonedDateTime> getFunction(String format, ZoneId zoneId, Locale
TemporalAccessor accessor = formatter.parse(text);
// if there is no year nor year-of-era, we fall back to the current one and
// fill the rest of the date up with the parsed date
if (accessor.isSupported(ChronoField.YEAR) == false && accessor.isSupported(ChronoField.YEAR_OF_ERA) == false ) {
if (accessor.isSupported(ChronoField.YEAR) == false /*&& accessor.isSupported(ChronoField.YEAR_OF_ERA) == false */) {
int year = LocalDate.now(ZoneOffset.UTC).getYear();
ZonedDateTime newTime = Instant.EPOCH.atZone(ZoneOffset.UTC).withYear(year);
for (ChronoField field : FIELDS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ public static ZonedDateTime from(TemporalAccessor accessor) {
zoneId = ZoneOffset.UTC;
}

LocalDate localDate = accessor.query(LOCAL_DATE_QUERY);
LocalDate localDate = accessor.query(TemporalQueries.localDate());//accessor.query(LOCAL_DATE_QUERY);
LocalTime localTime = accessor.query(TemporalQueries.localTime());
boolean isLocalDateSet = localDate != null;
boolean isLocalTimeSet = localTime != null;
Expand All @@ -1859,8 +1859,10 @@ public static ZonedDateTime from(TemporalAccessor accessor) {
if (accessor.isSupported(MONTH_OF_YEAR)) {
return getFirstOfMonth(accessor).atStartOfDay(zoneId);
} else {
int year = getYear(accessor);
return Year.of(year).atDay(1).atStartOfDay(zoneId);
return Year.of(accessor.get(ChronoField.YEAR)).atDay(1).atStartOfDay(zoneId);

// int year = getYear(accessor);
// return Year.of(year).atDay(1).atStartOfDay(zoneId);
}
} else if (accessor.isSupported(MONTH_OF_YEAR)) {
// missing year, falling back to the epoch and then filling
Expand Down Expand Up @@ -1941,6 +1943,8 @@ private static ZonedDateTime of(LocalDate localDate, LocalTime localTime, ZoneId

@SuppressForbidden(reason = "LocalDate.of is fine here")
private static LocalDate getFirstOfMonth(TemporalAccessor accessor) {
return LocalDate.of(getYear(accessor), accessor.get(MONTH_OF_YEAR), 1);
// return LocalDate.of(getYear(accessor), accessor.get(MONTH_OF_YEAR), 1);
return LocalDate.of(accessor.get(ChronoField.YEAR), accessor.get(MONTH_OF_YEAR), 1);

}
}

0 comments on commit 4ebd7b5

Please sign in to comment.