1.6.3 parsing timezones
This commit is contained in:
@@ -62,7 +62,8 @@ def create_airports_by_airportsList(airportsList, city=None):
|
|||||||
if airport.geo_lat and airport.geo_lon and not airport.timezone:
|
if airport.geo_lat and airport.geo_lon and not airport.timezone:
|
||||||
airport.timezone = tzf.timezone_at(
|
airport.timezone = tzf.timezone_at(
|
||||||
lng=float(airport.geo_lon), lat=float(airport.geo_lat))
|
lng=float(airport.geo_lon), lat=float(airport.geo_lat))
|
||||||
airport.save(update_fields=['timezone'])
|
airport.modifiedDT = datetime.now()
|
||||||
|
airport.save()
|
||||||
print(f'airport {airport.international_name} - {airport.timezone}')
|
print(f'airport {airport.international_name} - {airport.timezone}')
|
||||||
except Airport.DoesNotExist:
|
except Airport.DoesNotExist:
|
||||||
print(f' - - {airport_Dict["iata"]} не найден в БД > добавляем')
|
print(f' - - {airport_Dict["iata"]} не найден в БД > добавляем')
|
||||||
@@ -89,6 +90,8 @@ def create_airports_by_airportsList(airportsList, city=None):
|
|||||||
|
|
||||||
'iata_code': airport_Dict['iata'],
|
'iata_code': airport_Dict['iata'],
|
||||||
'icao_code': airport_Dict['icao'],
|
'icao_code': airport_Dict['icao'],
|
||||||
|
|
||||||
|
'modifiedDT': datetime.now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if airport_Dict['name:ru']:
|
if airport_Dict['name:ru']:
|
||||||
|
|||||||
@@ -60,7 +60,15 @@ class City(BaseModel):
|
|||||||
else:
|
else:
|
||||||
return f'{self.id}'
|
return f'{self.id}'
|
||||||
|
|
||||||
|
def get_n_save_timezone(self):
|
||||||
|
from ReferenceDataApp.funcs import tzf
|
||||||
|
self.timezone = tzf.timezone_at(lng=self.geo_lon, lat=self.geo_lat)
|
||||||
|
self.save(update_fields=['timezone'])
|
||||||
|
return self.timezone
|
||||||
|
|
||||||
def get_current_datetime(self):
|
def get_current_datetime(self):
|
||||||
|
if not self.timezone:
|
||||||
|
self.timezone = self.get_n_save_timezone()
|
||||||
return datetime.now(tz=pytz.timezone(self.timezone))
|
return datetime.now(tz=pytz.timezone(self.timezone))
|
||||||
|
|
||||||
def get_country_n_city_str(self):
|
def get_country_n_city_str(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user