Skip to content

Commit ced2280

Browse files
authored
Fix timezone (#1)
1 parent d613bbc commit ced2280

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ A timeline contains two critical pieces:
6161

6262
1. A list of events (in the form of a YAML list, JSON list, or CSV).
6363

64-
- Each event must have at least `start` key, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date(time) format, which can also have a suffix [time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) in parenthesise, e.g. `2020-02-03 12:34:56 (europe/zurich)`.
64+
- Each event must have at least `start` key, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date(time) format, which can also have a suffix [time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) in parenthesise, e.g. `2020-02-03 12:34:56 (Europe/Zurich)`.
6565
- Each event can have an optional `duration` key, to specify the delta from the `start`.
6666
This is in the format e.g. `30 minutes 4 hours 1 day 2 months 3 years`.
6767
All units are optional and can be in any order, e.g. `4 hours 30 minutes` is the same as `30 minutes 4 hours 0 day 0 months 0 years`.
@@ -110,7 +110,7 @@ The event dictionary is available as the `e` variable, and the following additio
110110
:style: none
111111
112112
- start: 2022-02-03 22:00
113-
- start: 2021-02-03 22:00 (europe/zurich)
113+
- start: 2021-02-03 22:00 (Europe/Zurich)
114114
duration: 1 hour 30 minutes
115115
- start: 2020-02-03
116116
duration: 1 day

src/sphinx_timeline/dtime.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ def to_datetime(value: str | date | datetime, default_tz=timezone.utc) -> dateti
2626
final = datetime.fromisoformat(tz_match.group("dt").strip())
2727
try:
2828
tz = zoneinfo.ZoneInfo(tz_match.group("tz"))
29-
except Exception:
30-
raise ValueError(f"Invalid timezone: {tz_match.group('tz')!r}")
29+
except Exception as exc:
30+
raise ValueError(
31+
f"Invalid timezone: {tz_match.group('tz')!r}"
32+
# f"\navailable: {zoneinfo.available_timezones()!r}"
33+
) from exc
3134
final = final.replace(tzinfo=tz)
3235
else:
3336
# parse datetime without timezone

tests/fixtures/posttransform_html.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ basic
44

55
- start: 2021-02-03
66
name: 2nd draft
7-
- start: 2022-02-03 02:00 (europe/zurich)
7+
- start: 2022-02-03 02:00 (Europe/Zurich)
88
name: 3rd draft
99
- start: "2020-02-03 05:00"
1010
name: 1st draft

0 commit comments

Comments
 (0)