mirror of
https://github.com/pyro2927/SouthwestCheckin.git
synced 2025-12-06 01:13:19 +00:00
16 lines
487 B
Python
16 lines
487 B
Python
import requests
|
|
import json
|
|
import pytz
|
|
|
|
|
|
def timezone_for_airport(airport_code):
|
|
tzrequest = {'iata': airport_code,
|
|
'country': 'ALL',
|
|
'db': 'airports',
|
|
'iatafilter': 'true',
|
|
'action': 'SEARCH',
|
|
'offset': '0'}
|
|
tzresult = requests.post("https://openflights.org/php/apsearch.php", tzrequest)
|
|
airport_tz = pytz.timezone(json.loads(tzresult.text)['airports'][0]['tz_id'])
|
|
return airport_tz
|