apognu / gocal

ICS file parser in Golang
MIT License
77 stars 24 forks source link

gocal can't retrieve a multiday event that borders with the end Date #16

Closed Tamh closed 1 year ago

Tamh commented 3 years ago

For this purpose, imagine the following event, as defined in the ICS file.

BEGIN:VEVENT
DTSTART:20210430T230000Z
DTEND:20210501T170000Z
DTSTAMP:20210411T052116Z
UID:xxxxx@google.com
CREATED:20210411T041911Z
DESCRIPTION:
LAST-MODIFIED:20210411T043219Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Test Event 4
TRANSP:OPAQUE
END:VEVENT

(an event that starts on April 30th, 11PM UTC and ends on May 1st, 5PM UTC

And the following code in Go:

    startTime := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.Local)
    endTime := time.Date(year, time.Month(month+1), -1, 23, 59, 59, 999999999, time.Local)
    iCalParser.Start, iCalParser.End = &startTime, &endTime

(where year=2021, month=4)

gocal doesn't retrieve this particular event for the calendar, though it should since it started on April 30th. I'm in UTC-5 (making the events start 5 hours early for me), so I don't think it has something to do with my locale.

If I change the code to:

    startTime := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.Local)
    endTime := time.Date(year, time.Month(month+1), 1, 0, 0, 0, 0, time.Local)
    iCalParser.Start, iCalParser.End = &startTime, &endTime

it retrieves it correctly.

apognu commented 3 years ago

endTime := time.Date(year, time.Month(month+1), -1, 23, 59, 59, 999999999, time.Local)

This line actually resolves to 2021-04-29 23:59:59.999999999 +0000 UTC, which would completely exclude this event, which starts on April, 30th. On this particular instance, I understand gocal's logic is sound.

There may be some other issue with the framing, but I cannot see one here. Do you agree?

apognu commented 1 year ago

Closing for inactivity.