mirror of
https://github.com/pyro2927/SouthwestCheckin.git
synced 2025-12-06 01:13:19 +00:00
Properly localize airport timezones
This commit is contained in:
@@ -105,7 +105,9 @@ def auto_checkin(reservation_number, first_name, last_name):
|
|||||||
# calculate departure for this leg
|
# calculate departure for this leg
|
||||||
airport = "{}, {}".format(leg['departureAirport']['name'], leg['departureAirport']['state'])
|
airport = "{}, {}".format(leg['departureAirport']['name'], leg['departureAirport']['state'])
|
||||||
takeoff = "{} {}".format(leg['departureDate'], leg['departureTime'])
|
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:
|
if date > now:
|
||||||
# found a flight for checkin!
|
# found a flight for checkin!
|
||||||
print("Flight information found, departing {} at {}".format(airport, date.strftime('%b %d %I:%M%p')))
|
print("Flight information found, departing {} at {}".format(airport, date.strftime('%b %d %I:%M%p')))
|
||||||
|
|||||||
Reference in New Issue
Block a user