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

GetOccurences not respecting different timezones in ICS file #569

Open
adamvaul opened this issue Mar 14, 2023 · 1 comment
Open

GetOccurences not respecting different timezones in ICS file #569

adamvaul opened this issue Mar 14, 2023 · 1 comment

Comments

@adamvaul
Copy link

adamvaul commented Mar 14, 2023

Below is the ics file. If I use the following lines of code for just UTC timezone, then it does not return all the information for all the events.

Test Code
using System;
using System.Globalization;

public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");

	var icsData = "BEGIN:VCALENDAR\nVERSION:2.0\nCALSCALE:GREGORIAN\nPRODID:bitcentralfuel/ics\nMETHOD:PUBLISH\nX-PUBLISHED-TTL:PT1H\nX-WR-TIMEZONE:America/Los_Angeles\nBEGIN:VTIMEZONE\nTZID:America/Los_Angeles\nX-LIC-LOCATION:America/Los_Angeles\nLAST-MODIFIED:20230103T195358Z\nBEGIN:DAYLIGHT\nTZNAME:PDT\nTZOFFSETFROM:-0800\nTZOFFSETTO:-0700\nDTSTART;TZID=\"America/Los_Angeles\":19700308T020000\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\nEND:DAYLIGHT\nBEGIN:STANDARD\nTZNAME:PST\nTZOFFSETFROM:-0700\nTZOFFSETTO:-0800\nDTSTART;TZID=\"America/Los_Angeles\":19701101T020000\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\nEND:STANDARD\nEND:VTIMEZONE\nBEGIN:VEVENT\nUID:e16adea0-0492-4823-be92-4457c3fc5560\nSUMMARY:1pm PST (1)\nDTSTAMP:20230314T192900Z\nDTSTART;TZID=America/Los_Angeles:20230314T130000\nDTEND;TZID=America/Los_Angeles:20230314T133000\nCATEGORIES:\nEND:VEVENT\nBEGIN:VEVENT\nUID:9315557b-353e-4bce-9a08-3531faf4bb14\nSUMMARY:3pm PST (5)\nDTSTAMP:20230314T192900Z\nDTSTART;TZID=America/Los_Angeles:20230314T150000\nDTEND;TZID=America/Los_Angeles:20230314T153000\nCATEGORIES:\nEND:VEVENT\nBEGIN:VEVENT\nUID:3d036279-5e19-421a-a8c2-3655b95d08b7\nSUMMARY:5pm PST (9)\nDTSTAMP:20230314T192900Z\nDTSTART;TZID=America/Los_Angeles:20230314T170000\nDTEND;TZID=America/Los_Angeles:20230314T173000\nCATEGORIES:\nEND:VEVENT\nEND:VCALENDAR\n";
	
	Ical.Net.Calendar calendar = Ical.Net.Calendar.Load(icsData);
	
	Console.WriteLine(calendar.ToString());
	
	
	var fromDate2 = new DateTime(2023, 3, 14, 20, 19, 0, DateTimeKind.Utc);
	var toDate2 = fromDate2.AddDays(14);

	var zFromDate = new Ical.Net.DataTypes.CalDateTime(fromDate2, "Etc/UTC");
	var zToDate = new Ical.Net.DataTypes.CalDateTime(toDate2, "Etc/UTC");

	var occ = calendar.GetOccurrences(zFromDate, zToDate);
	
	
	
	Console.WriteLine(occ.Count);
	
	
}

}

ICS File

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:bitcentralfuel/ics
METHOD:PUBLISH
X-PUBLISHED-TTL:PT1H
X-WR-TIMEZONE:America/Los_Angeles
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
X-LIC-LOCATION:America/Los_Angeles
LAST-MODIFIED:20230103T195358Z
BEGIN:DAYLIGHT
TZNAME:PDT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
DTSTART;TZID="America/Los_Angeles":19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:PST
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
DTSTART;TZID="America/Los_Angeles":19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:e16adea0-0492-4823-be92-4457c3fc5560
SUMMARY:1pm PST (1)
DTSTAMP:20230314T192900Z
DTSTART;TZID=America/Los_Angeles:20230314T130000
DTEND;TZID=America/Los_Angeles:20230314T133000
CATEGORIES:
END:VEVENT
BEGIN:VEVENT
UID:9315557b-353e-4bce-9a08-3531faf4bb14
SUMMARY:3pm PST (5)
DTSTAMP:20230314T192900Z
DTSTART;TZID=America/Los_Angeles:20230314T150000
DTEND;TZID=America/Los_Angeles:20230314T153000
CATEGORIES:
END:VEVENT
BEGIN:VEVENT
UID:3d036279-5e19-421a-a8c2-3655b95d08b7
SUMMARY:5pm PST (9)
DTSTAMP:20230314T192900Z
DTSTART;TZID=America/Los_Angeles:20230314T170000
DTEND;TZID=America/Los_Angeles:20230314T173000
CATEGORIES:
END:VEVENT
END:VCALENDAR

@minichma
Copy link

Might be a duplicate of or at least related to #406.

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

2 participants