diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e20212..3dd7df7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,14 +23,14 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install poetry==1.1.11 + pip install poetry==1.8.3 - name: Build package run: poetry build - name: Upload packages to Jazzband if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: jazzband password: ${{ secrets.JAZZBAND_RELEASE_KEY }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4040808..0306208 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,4 +31,4 @@ jobs: - name: 'Upload coverage to Codecov' uses: codecov/codecov-action@v4 with: - fail_ci_if_error: true + fail_ci_if_error: false diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 586e3fb..79aee99 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -365,12 +365,42 @@ def parse_events( if type(s) is date and e.recurring == False: f, t = start, end elif type(s) is datetime and s.tzinfo: - f, t = datetime( - start.year, start.month, start.day, tzinfo=s.tzinfo - ), datetime(end.year, end.month, end.day, tzinfo=s.tzinfo) + f = ( + datetime( + start.year, + start.month, + start.day, + start.hour, + start.minute, + tzinfo=s.tzinfo, + ) + if type(start) == datetime + else datetime(start.year, start.month, start.day, tzinfo=s.tzinfo) + ) + t = ( + datetime( + end.year, + end.month, + end.day, + end.hour, + end.minute, + tzinfo=s.tzinfo, + ) + if type(end) == datetime + else datetime(end.year, end.month, end.day, tzinfo=s.tzinfo) + ) else: - f, t = datetime(start.year, start.month, start.day), datetime( - end.year, end.month, end.day + f = ( + datetime( + start.year, start.month, start.day, start.hour, start.minute + ) + if type(start) == datetime + else datetime(start.year, start.month, start.day) + ) + t = ( + datetime(end.year, end.month, end.day, end.hour, end.minute) + if type(end) == datetime + else datetime(end.year, end.month, end.day) ) if e.recurring: diff --git a/pyproject.toml b/pyproject.toml index 9b91309..4585cc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "icalevents" -version = "0.1.27" +version = "0.1.28" description = "Simple Python 3 library to download, parse and query iCal sources." authors = ["Martin Eigenmann ", "Thomas Irgang ", "Alexander Hultnér "] diff --git a/test/test_data/small_time_frame.ics b/test/test_data/small_time_frame.ics new file mode 100644 index 0000000..f441fda --- /dev/null +++ b/test/test_data/small_time_frame.ics @@ -0,0 +1,91 @@ +BEGIN:VCALENDAR +METHOD:PUBLISH +PRODID:Microsoft Exchange Server 2010 +VERSION:2.0 +X-WR-CALNAME:Calendar +BEGIN:VTIMEZONE +TZID:Pacific Standard Time +BEGIN:STANDARD +DTSTART:16010101T020000 +TZOFFSETFROM:-0700 +TZOFFSETTO:-0800 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:16010101T020000 +TZOFFSETFROM:-0800 +TZOFFSETTO:-0700 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;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:VTIMEZONE +TZID:Central Standard Time +BEGIN:STANDARD +DTSTART:16010101T020000 +TZOFFSETFROM:-0500 +TZOFFSETTO:-0600 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:16010101T020000 +TZOFFSETFROM:-0600 +TZOFFSETTO:-0500 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VTIMEZONE +TZID:Eastern Standard Time +BEGIN:STANDARD +DTSTART:16010101T020000 +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:16010101T020000 +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VTIMEZONE +TZID:India Standard Time +BEGIN:STANDARD +DTSTART:16010101T000000 +TZOFFSETFROM:+0530 +TZOFFSETTO:+0530 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:16010101T000000 +TZOFFSETFROM:+0530 +TZOFFSETTO:+0530 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +UID:0400AAAA8200E00074C5B7101A82E0080000000085E5DC3409AAAA01000000000000000 + 010000000AAAADE08C53CAA4283D0AAA1A2AAA97 +SUMMARY:TEST Summary +DTSTART;TZID=Pacific Standard Time:20230509T090000 +DTEND;TZID=Pacific Standard Time:20230509T100000 +CLASS:PUBLIC +PRIORITY:5 +DTSTAMP:20230509T014745Z +TRANSP:OPAQUE +STATUS:CONFIRMED +SEQUENCE:0 +LOCATION: +END:VEVENT +END:VCALENDAR diff --git a/test/test_icalevents.py b/test/test_icalevents.py index 0f88de2..a716f9d 100644 --- a/test/test_icalevents.py +++ b/test/test_icalevents.py @@ -862,6 +862,17 @@ class ICalEventsTests(unittest.TestCase): "starts at 5 utc summer time (+2:00)", ) + def test_small_time_frame(self): + ical = "test/test_data/small_time_frame.ics" + + PT = gettz("America/Los_Angeles") + start = datetime(month=5, day=9, year=2023, tzinfo=PT) + end = datetime(month=5, day=9, year=2023, hour=23, tzinfo=PT) + + events = icalevents.events(file=ical, start=start, end=end, strict=True) + + self.assertEqual(len(events), 1, "1 events") + def test_regression_repeating_events_raise_an_error(self): ical = "test/test_data/recurrence_tzinfo.ics" start = date(2023, 1, 1)