mergecal / python-mergecal

Python library and CLI tool to merge RFC5545 iCalendar feeds and .ics files.
https://mergecal.readthedocs.io/
GNU General Public License v3.0
6 stars 0 forks source link

vtimezone: collect all vtimezone from source calendars #1

Open abe-101 opened 2 months ago

abe-101 commented 2 months ago

currently we only merge vevents its import to also gather vtimezone from each calendar and include it in the results

niccokunzmann commented 2 months ago

This is the code I use in the OpenWebCalendar:

https://github.com/niccokunzmann/open-web-calendar/blob/67991b6fadc3bf75bdfecfe9c4d3e6ea0e4d55bd/open_web_calendar/convert_to_ics.py#L35

Timezones with the same name are assumed to be the same. I do think that we should do that.

abe-101 commented 2 months ago

thanks for the reference - i see that you remove duplicate tzids that makes sense to me I just wonder what we should be doing if 2 calendars define the same tzid differently :shrug:

here is some psudocode

def merge(self) -> Calendar:
    """Merge the calendars."""
    existing_tzids = set()
    for cal in self.calendars:
        for component in cal.walk("VTIMEZONE"):
            tzid = component.get("tzid")
            if tzid in existing_tzids:
                continue
            existing_tzids.add(tzid)
            self.merged_calendar.add_component(component)

        for component in cal.walk("VEVENT"):
            ....
niccokunzmann commented 2 months ago

what we should be doing if 2 calendars define the same tzid differently

I think, it is OK to remove duplication as the name is what is meant. I would say that the names are mostly standardized and we will not likely encounter a problem.