update tww
This commit is contained in:
parent
8430260527
commit
b2d161a0e6
@ -45,3 +45,4 @@ mountain view,14.1194444,15.3133335
|
|||||||
in,6.9833333,171.6999969
|
in,6.9833333,171.6999969
|
||||||
ind,20.0,77.0
|
ind,20.0,77.0
|
||||||
indi,20.0,77.0
|
indi,20.0,77.0
|
||||||
|
local,37.6666667,-1.7
|
||||||
|
|
17
tww/tww.py
17
tww/tww.py
@ -259,6 +259,15 @@ def resolve_timezone(query):
|
|||||||
# if the human_tz_loc contains /, assume it's a timezone which could be
|
# if the human_tz_loc contains /, assume it's a timezone which could be
|
||||||
# incorrectly written with small letters - need Continent/City
|
# incorrectly written with small letters - need Continent/City
|
||||||
normal_query = query.lower().strip()
|
normal_query = query.lower().strip()
|
||||||
|
if normal_query in ['local']:
|
||||||
|
local_iana = get_local_tzname_iana()
|
||||||
|
local_offset = get_local_tz_offset()
|
||||||
|
return {
|
||||||
|
"query": query,
|
||||||
|
"normal_query": normal_query,
|
||||||
|
"tz_offset": local_offset,
|
||||||
|
"tz_name": local_iana,
|
||||||
|
}
|
||||||
found_from_iana_tz = NORMALIZED_TZ_DICT.get(normal_query, "")
|
found_from_iana_tz = NORMALIZED_TZ_DICT.get(normal_query, "")
|
||||||
found_from_abbr_tzs = list(NORMALIZED_TZ_ABBR.get(normal_query, set()))
|
found_from_abbr_tzs = list(NORMALIZED_TZ_ABBR.get(normal_query, set()))
|
||||||
found_from_offset_tz, offset_tzs = find_from_offset(normal_query)
|
found_from_offset_tz, offset_tzs = find_from_offset(normal_query)
|
||||||
@ -319,7 +328,7 @@ def resolve_timezone(query):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def solve_query(human_dt, human_tz_loc):
|
def solve_query(human_dt, human_tz_loc=None):
|
||||||
try:
|
try:
|
||||||
# first try parsing the timezone from user input
|
# first try parsing the timezone from user input
|
||||||
result = dateparser.parse(human_dt, settings={'RETURN_AS_TIMEZONE_AWARE': True})
|
result = dateparser.parse(human_dt, settings={'RETURN_AS_TIMEZONE_AWARE': True})
|
||||||
@ -604,8 +613,10 @@ def get_local_tzname_iana():
|
|||||||
|
|
||||||
|
|
||||||
def get_local_tz_offset():
|
def get_local_tz_offset():
|
||||||
return format_offset_from_timedelta(
|
now = datetime.now(tzlocal())
|
||||||
datetime.now(tzlocal()).tzinfo._std_offset)
|
if now.tzinfo._isdst(now):
|
||||||
|
return format_offset_from_timedelta(now.tzinfo._dst_offset)
|
||||||
|
return format_offset_from_timedelta(now.tzinfo._std_offset)
|
||||||
|
|
||||||
|
|
||||||
def tzname_to_tz_offset(tzname_iana: str):
|
def tzname_to_tz_offset(tzname_iana: str):
|
||||||
|
Loading…
Reference in New Issue
Block a user