Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def addtimezone(lat, lon):
try:
import timezonefinder
tf = timezonefinder.TimezoneFinder()
return (lat, lon, tf.timezone_at(lng=float(lon), lat=float(lat)))
#return (lat, lon, 'America/Los_Angeles') # FIXME
except ValueError:
return (lat, lon, 'TIMEZONE') # header
def addtimezone(lat, lon):
try:
import timezonefinder
tf = timezonefinder.TimezoneFinder()
return (lat, lon, tf.timezone_at(lng=float(lon), lat=float(lat)))
#return (lat, lon, 'America/Los_Angeles') # FIXME
except ValueError:
return (lat, lon, 'TIMEZONE') # header
from dancedeets.search import search
from dancedeets.nlp import categories
from dancedeets.nlp import event_classifier
from dancedeets.util import dates
from dancedeets.util import fb_events
from dancedeets.util import language
from dancedeets.util import timelog
from . import event_image
from . import event_locations
from . import namespaces
from . import web_events_reloading
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
DATETIME_FORMAT_TZ = "%Y-%m-%dT%H:%M:%S%z"
timezone_finder = TimezoneFinder()
reload_functions = {
namespaces.CHINA_JWJAM_JAM: web_events_reloading.fetch_jwjam_jam,
namespaces.CHINA_JWJAM_COURSE: web_events_reloading.fetch_jwjam_course,
}
def reload_web_events(web_events, disable_updates=None):
events_to_update = []
for web_event in web_events:
if web_event.namespace in reload_functions:
func = reload_functions[web_event.namespace]
new_json = func(web_event)
events_to_update.append((web_event, new_json))
else:
events_to_update.append((web_event, web_event.web_event))
calprev = str(calendar.month(prev.year, prev.month))
calnext = str(calendar.month(next.year, next.month))
times = {}
fmt = '%Y-%m-%d %H:%M'
now_utc = datetime.datetime.now(timezone('UTC'))
now_ny = now_utc.astimezone(timezone('US/Eastern'))
times['ny'] = now_ny.strftime(fmt)
times['utc'] = now_utc.strftime(fmt)
now_tr = now_utc.astimezone(timezone('Turkey'))
times['tr'] = now_tr.strftime(fmt)
tf = timezonefinder.TimezoneFinder()
timezone_str = tf.certain_timezone_at(lat=lat, lng=lon)
now_curr = now_utc.astimezone(timezone(timezone_str))
times['curr'] = now_curr.strftime(fmt)
weekday = list(calendar.day_name)[now_utc.weekday()]
return render_template('/time.html',
calprev=calprev,
calcurr=calcurr,
calnext=calnext,
times=times,
weekday=weekday,
tzone=timezone_str)
def addtimezone(lat, lon):
try:
import timezonefinder
tf = timezonefinder.TimezoneFinder()
return (lat, lon, tf.timezone_at(lng=float(lon), lat=float(lat)))
#return (lat, lon, 'America/Los_Angeles') # FIXME
except ValueError:
return (lat, lon, 'TIMEZONE') # header
def addtimezone(lat, lon):
try:
import timezonefinder
tf = timezonefinder.TimezoneFinder()
return (lat, lon, tf.timezone_at(lng=float(lon), lat=float(lat)))
#return (lat, lon, 'America/Los_Angeles') # FIXME
except ValueError:
return (lat, lon, 'TIMEZONE') # header
from timezonefinder import TimezoneFinder
TimezoneFinder.using_numba() # this is a static method returning True or False
tf = TimezoneFinder()
# or
tf = TimezoneFinder(in_memory=True)
longitude, latitude = 13.358, 52.5061
tf.timezone_at(lng=longitude, lat=latitude) # returns 'Europe/Berlin'
tf.certain_timezone_at(lng=longitude, lat=latitude) # returns 'Europe/Berlin'
longitude = 12.773955
latitude = 55.578595
tf.closest_timezone_at(lng=longitude, lat=latitude) # returns 'Europe/Copenhagen'
longitude = 42.1052479
latitude = -16.622686
tf.closest_timezone_at(lng=longitude, lat=latitude, delta_degree=2, exact_computation=True, return_distances=True,
def addtimezone(lat, lon):
try:
import timezonefinder
tf = timezonefinder.TimezoneFinder()
tz = tf.timezone_at(lng=float(lon), lat=float(lat))
if tz is None:
tz = 'UTC'
return (lat, lon, tz)
except ValueError:
return (lat, lon, 'TIMEZONE') # header
from timezonefinder import TimezoneFinder
TimezoneFinder.using_numba() # this is a static method returning True or False
tf = TimezoneFinder()
# or
tf = TimezoneFinder(in_memory=True)
longitude, latitude = 13.358, 52.5061
tf.timezone_at(lng=longitude, lat=latitude) # returns 'Europe/Berlin'
tf.certain_timezone_at(lng=longitude, lat=latitude) # returns 'Europe/Berlin'
longitude = 12.773955
latitude = 55.578595
tf.closest_timezone_at(lng=longitude, lat=latitude) # returns 'Europe/Copenhagen'
longitude = 42.1052479
latitude = -16.622686
tf.closest_timezone_at(lng=longitude, lat=latitude, delta_degree=2, exact_computation=True, return_distances=True,
force_evaluation=True)