Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems with daylight saving times #28

Open
Ro-C-Me opened this issue Nov 24, 2022 · 0 comments
Open

problems with daylight saving times #28

Ro-C-Me opened this issue Nov 24, 2022 · 0 comments

Comments

@Ro-C-Me
Copy link

Ro-C-Me commented Nov 24, 2022

Hi,

not quite sure if it's ok to post this here, but... I'll give it a try :)

I'm trying to parse an ICS file from office365 / outlook. It's seems to work in general, but I always get the results with "+02:00" (probably European summer time) instead of "+01:00" (European winter time).

Probably, this isn't a issue with the library, but with me or my code, but even after thinking for days, I can't figure out whats wrong...

Here is what I'm currently doing in my unit test:

	@Test
	public void testRecurringWednesday_minimal() throws FileNotFoundException, IOException, ParserException {
		File testFile = new File("src/test/resources/recurring_wednesday.ics");
		assertTrue(testFile.exists(), "test file not found: " + testFile.getAbsolutePath());
		
		Calendar calendar = null;
		TimeZoneRegistry createRegistry = new OutlookTimeZoneRegistryFactory().createRegistry();
		calendar = new CalendarBuilder(createRegistry)
				.build(new DataInputStream(new FileInputStream(testFile)));
		
		ZonedDateTime begin = ZonedDateTime.of(2022, 11, 30, 0, 0, 0, 0, ZoneId.of("Europe/Berlin"));
		Period period = new Period<Temporal>(begin, Minutes.of(1600));
		// TODO how to remove all CANCELLED events?
		Filter<VEvent> filter = new Filter<VEvent>(new PeriodRule(period ));

		Collection<VEvent> upcoming = filter
				.filter(calendar.getComponents(net.fortuna.ical4j.model.Component.VEVENT));

		log.info("Found " + upcoming.size() + " events");
		upcoming.stream().forEach(e -> {
			Set<Period<Temporal>> recs = e.calculateRecurrenceSet(period);
			recs.stream().forEach(r-> {log.info("Begin: " + r.getStart());});
		});

	}

My (test) ics calendar content with 2 events is:

BEGIN:VCALENDAR
METHOD:PUBLISH
PRODID:Microsoft Exchange Server 2010
VERSION:2.0
X-WR-CALNAME:Kalender
BEGIN:VTIMEZONE
TZID:W. Europe Standard Time
BEGIN:STANDARD
DTSTART:16010101T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:UTC
BEGIN:STANDARD
DTSTART:16010101T000000
TZOFFSETFROM:+0000
TZOFFSETTO:+0000
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T000000
TZOFFSETFROM:+0000
TZOFFSETTO:+0000
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
RRULE:FREQ=WEEKLY;UNTIL=20230517T073000Z;INTERVAL=1;BYDAY=WE;WKST=SU
UID:040000008200E00074C5B7101A82E00800000000C6C9CF59F6D9D701000000000000000
 010000000CAD7F28AF2E7284AB42C744A1579929E
SUMMARY:Gebucht
DTSTART;TZID=W. Europe Standard Time:20221026T093000
DTEND;TZID=W. Europe Standard Time:20221026T100000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20221120T215710Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:2
X-MICROSOFT-CDO-APPT-SEQUENCE:2
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:1
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
END:VEVENT
BEGIN:VEVENT
UID:040000008200E00074C5B7101A82E0080000000039D3E9AD4100D901000000000000000
 0100000008A2284A522B45947B4A4B5059BC45069
SUMMARY:Frei
DTSTART;TZID=W. Europe Standard Time:20221130T093200
DTEND;TZID=W. Europe Standard Time:20221130T093500
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20221124T201701Z
TRANSP:TRANSPARENT
STATUS:CONFIRMED
SEQUENCE:0
X-MICROSOFT-CDO-APPT-SEQUENCE:0
X-MICROSOFT-CDO-BUSYSTATUS:FREE
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
END:VEVENT
END:VCALENDAR

Currently, I get

Begin: 2022-11-30T09:30+02:00
Begin: 2022-11-30T09:32+02:00

and this is one hour too early for me ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant