MenoData / Time4J

Advanced date, time and interval library for Java with sun/moon-astronomy and calendars like Chinese, Coptic, Ethiopian, French Republican, Hebrew, Hijri, Historic Christian, Indian National, Japanese, Julian, Korean, Minguo, Persian, Thai, Vietnamese
GNU Lesser General Public License v2.1
424 stars 62 forks source link

Crash in OldApiTimezone when Saturday is hit #939

Closed MenoData closed 3 years ago

MenoData commented 3 years ago

Row 88: } else if (dayOfWeek < 1 || dayOfWeek >= 7) { validates in the wrong range. Reported by a thoughtful user. Following test should succeed but actually fails:

    @Test
    public void oldApiTimezone() {
        Timezone tz = Timezone.of("Europe/Rome");
        assertThat(
            TemporalType.JAVA_UTIL_TIMEZONE.from(tz).getOffset(
                GregorianCalendar.AD, 2020, Calendar.JULY, 4, Calendar.SATURDAY, 0),
            is(2 * 3600 * 1000));
    }