From 87462e3950e256df23f6f21a8bfe7f8b16a6fd31 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 27 Oct 2023 23:41:42 +0200 Subject: [PATCH] Fixed iCal timezone https://github.com/mangstadt/biweekly/issues/126 --- app/src/main/java/biweekly/io/ICalTimeZone.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/biweekly/io/ICalTimeZone.java b/app/src/main/java/biweekly/io/ICalTimeZone.java index 78e6200869..52abbcc070 100644 --- a/app/src/main/java/biweekly/io/ICalTimeZone.java +++ b/app/src/main/java/biweekly/io/ICalTimeZone.java @@ -422,14 +422,19 @@ public class ICalTimeZone extends TimeZone { * to the "last" date. But this causes all the unit tests to fail, * so I guess not. */ - it.advanceTo(last); + //it.advanceTo(last); //it.next(); DateValue prev = null, cur = null; boolean stopped = false; while (it.hasNext()) { cur = it.next(); - dateCache.add(cur); + int curComparison = cur.compareTo(last); + if (curComparison < 0) continue; + + if (curComparison > 0) { + dateCache.add(cur); + } if (givenDate.compareTo(cur) < 0) { //stop if we have passed the givenTime @@ -439,8 +444,7 @@ public class ICalTimeZone extends TimeZone { prev = cur; } - return after ? (stopped ? cur : null) : prev; - } + return after ? (stopped ? cur : null) : prev; } /* * The date is somewhere in the cached list, so find it.