Skip to content

Commit

Permalink
Fix bug where parsing the rare occurence of leap-second without time-…
Browse files Browse the repository at this point in the history
…offset in date-time would fail
  • Loading branch information
Morten Haraldsen committed Jan 23, 2024
1 parent 03c26c5 commit 2c358c1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/com/ethlo/time/internal/EthloITU.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ private static Object handleTime(int year, int month, int day, int hour, int min
if (remaining == 2)
{
final int seconds = parsePositiveInt(chars, 17, 19);
leapSecondCheck(year, month, day, hour, minute, 0, 0, null);
if (raw)
{
return new DateTime(Field.SECOND, year, month, day, hour, minute, seconds, 0, null, 0);
Expand Down Expand Up @@ -389,10 +388,10 @@ else if (c == PLUS || c == MINUS)
}

final int second = parsePositiveInt(chars, 17, 19);
leapSecondCheck(year, month, day, hour, minute, second, fractions, offset);

if (!raw)
{
leapSecondCheck(year, month, day, hour, minute, second, fractions, offset);
return OffsetDateTime.of(year, month, day, hour, minute, second, fractions, offset.toZoneOffset());
}
return fractionDigits > 0 ? DateTime.of(year, month, day, hour, minute, second, fractions, offset, fractionDigits) : DateTime.of(year, month, day, hour, minute, second, offset);
Expand All @@ -415,8 +414,8 @@ private static void leapSecondCheck(int year, int month, int day, int hour, int
final boolean isValidLeapYearMonth = leapSecondHandler.isValidLeapSecondDate(needle);
if (isValidLeapYearMonth || needle.isAfter(leapSecondHandler.getLastKnownLeapSecond()))
{
final int utcHour = hour - (offset.getTotalSeconds() / 3_600);
final int utcMinute = minute - ((offset.getTotalSeconds() % 3_600) / 60);
final int utcHour = hour - (offset != null ? (offset.getTotalSeconds() / 3_600) : 0);
final int utcMinute = minute - (offset != null ? ((offset.getTotalSeconds() % 3_600) / 60) : 0);
if (((month == Month.DECEMBER.getValue() && day == 31) || (month == Month.JUNE.getValue() && day == 30))
&& utcHour == 23
&& utcMinute == 59)
Expand Down

0 comments on commit 2c358c1

Please sign in to comment.