diff --git a/pyproject.toml b/pyproject.toml index ff25dca..030cc91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "yaml2ics" version = "0.3rc1.dev0" -requires-python = ">=3.8" +requires-python = ">=3.9" authors = [{name = "Scientific Python Developers"}] readme = "README.md" license = {file = "LICENSE"} diff --git a/tests/test_cli.py b/tests/test_cli.py index f57e055..f4bbe9e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,9 +1,9 @@ import datetime import io import os +import zoneinfo import pytest -import zoneinfo from yaml2ics import event_from_yaml, files_to_events, main diff --git a/yaml2ics.py b/yaml2ics.py index 2227f1d..28b76be 100644 --- a/yaml2ics.py +++ b/yaml2ics.py @@ -8,12 +8,12 @@ import datetime import os import sys +import zoneinfo import dateutil import dateutil.rrule import ics import yaml -import zoneinfo from dateutil.tz import gettz as _gettz interval_type = { @@ -70,6 +70,7 @@ def event_from_yaml(event_yaml: dict, tz: datetime.tzinfo = None) -> ics.Event: if tz is None: tz = dateutil.tz.UTC + if "timezone" in d: tzname = d.pop("timezone") tz = gettz(tzname) @@ -95,6 +96,9 @@ def event_from_yaml(event_yaml: dict, tz: datetime.tzinfo = None) -> ics.Event: # or it was inferred from event start time. tz = event.timespan.begin_time.tzinfo + if not tz: + tz = dateutil.tz.UTC + # Handle all-day events if not ("duration" in d or "end" in d): event.make_all_day()