From 3686360aec1ca64d5eee0cf5202b78e28706392c Mon Sep 17 00:00:00 2001 From: pyro2927 Date: Thu, 28 Dec 2017 18:37:57 -0800 Subject: [PATCH] Properly localize airport timezones --- checkin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/checkin.py b/checkin.py index 67083b3..8b91cc8 100755 --- a/checkin.py +++ b/checkin.py @@ -105,7 +105,9 @@ def auto_checkin(reservation_number, first_name, last_name): # calculate departure for this leg airport = "{}, {}".format(leg['departureAirport']['name'], leg['departureAirport']['state']) takeoff = "{} {}".format(leg['departureDate'], leg['departureTime']) - date = datetime.strptime(takeoff, '%Y-%m-%d %H:%M').replace(tzinfo=g.timezone(g.geocode(airport).point)) + point = g.geocode(airport).point + airport_tz = g.timezone(point) + date = airport_tz.localize(datetime.strptime(takeoff, '%Y-%m-%d %H:%M')) if date > now: # found a flight for checkin! print("Flight information found, departing {} at {}".format(airport, date.strftime('%b %d %I:%M%p')))