From f758d4c54cf51723fe1b5e53407918472c63d74c Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Sat, 2 Jan 2021 15:38:49 +0100 Subject: [PATCH] Sync the latest updates --- hyperdia.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hyperdia.py b/hyperdia.py index 63d165f..bc07a54 100755 --- a/hyperdia.py +++ b/hyperdia.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 +# SPDX-FileCopyrightText: 2021 Luca Beltrame +# +# SPDX-License-Identifier: BSD-3-Clause + import argparse from dataclasses import dataclass from datetime import datetime @@ -196,13 +200,16 @@ def parse_station_time(element, year, month, day, start=True): # Otherwise we get the only item current_time = times[-1] if start else times[0] + tz = pytz.timezone("Japan") hour, minutes = current_time.split(":") station_time = datetime(year, int(month), int(day), int(hour), - int(minutes), - tzinfo=pytz.timezone("Japan")) + int(minutes)) + # Regular datetime with tzinfo screws things up, create a native time + # Then localize it with pytz (no DST, there's no such thing in Japan) + station_time = tz.localize(station_time, is_dst=False) return station_time