diff --git a/tww/data/.cache.csv b/tww/data/.cache.csv
index 4486de0..1ddfc55 100644
--- a/tww/data/.cache.csv
+++ b/tww/data/.cache.csv
@@ -46,3 +46,33 @@ in,6.9833333,171.6999969
ind,20.0,77.0
indi,20.0,77.0
local,37.6666667,-1.7
++02:,49.453285449999996,3.606899003594057
+it,33.6366667,42.8224983
+G,32.3293809,-83.1137366
+D,10.0,-67.166667
+dub,-32.25,148.6166687
+D,10.0,-67.166667
+dubli,53.3330556,-6.248889
+dublin,53.3330556,-6.248889
+Du,25.0750095,55.18876088183319
+dublin ,53.3330556,-6.248889
+S,35.7724185,127.79654346305617
+sof,42.6975135,23.3241463
+S,35.7724185,127.79654346305617
+sofia ,42.6975135,23.3241463
+S,35.7724185,127.79654346305617
+S,35.7724185,127.79654346305617
+du,-32.25,148.6166687
+D,10.0,-67.166667
+S,35.7724185,127.79654346305617
+S,35.7724185,127.79654346305617
+S,35.7724185,127.79654346305617
+S,35.7724185,127.79654346305617
+D,10.0,-67.166667
+D,10.0,-67.166667
+new y,6.9833333,171.6999969
+S,35.7724185,127.79654346305617
+S,35.7724185,127.79654346305617
+D,10.0,-67.166667
+dubl,53.3330556,-6.248889
+D,10.0,-67.166667
diff --git a/tww/lib.py b/tww/lib.py
index 6c2cc2e..cbde44c 100644
--- a/tww/lib.py
+++ b/tww/lib.py
@@ -33,12 +33,14 @@ from word2number import w2n
from tww.common import logger
FUZZ_THRESHOLD = 70
+ISO_Z_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
ISO_FORMAT = '%Y-%m-%dT%H:%M:%S%z'
+ISO_FORMAT_NO_TZ = '%Y-%m-%dT%H:%M:%S'
DEFAULT_FORMAT = '%Y-%m-%d %H:%M:%S%z'
basepath = os.path.dirname(os.path.abspath(__file__))
-SKIP_DATE_TOKENS = ['on', 'to', 'set', 'be']
+SKIP_DATE_TOKENS = ['on', 'to', 'set', 'be', 'an', "me"]
def parse_to_iso(dt, dt_hint=None):
@@ -52,7 +54,7 @@ def parse_to_iso(dt, dt_hint=None):
def find_dates_in(text):
rv = []
- dateparser_dates = search_dates(text, settings={"SKIP_TOKENS": SKIP_DATE_TOKENS})
+ dateparser_dates = search_dates(text)
if dateparser_dates:
rv += list(filter(_dateparser_search_filter, dateparser_dates))
try:
@@ -604,15 +606,17 @@ def get_local_now(tzaware: bool = True):
return datetime.utcnow()
+def split_offset(offset):
+ if ':' in offset:
+ to_shh, to_mm = offset.split(':')
+ else:
+ to_shh, to_mm = offset[:-2], offset[-2:]
+ return int(to_shh), int(to_mm)
+
+
def dt_tz_translation(dt: datetime, to_tz_offset: str, from_tz_offset: str = "+00:00") -> datetime:
- if ':' in to_tz_offset:
- to_shh, to_mm = to_tz_offset.split(':')
- else:
- to_shh, to_mm = to_tz_offset[:-2], to_tz_offset[-2:]
- if ':' in from_tz_offset:
- from_shh, from_mm = from_tz_offset.split(':')
- else:
- from_shh, from_mm = from_tz_offset[:-2], to_tz_offset[-2:]
+ to_shh, to_mm = split_offset(to_tz_offset)
+ from_shh, from_mm = split_offset(from_tz_offset)
tzinfo = tzinfo_from_offset(to_tz_offset)[0]
if dt.tzinfo:
return dt.astimezone(tzinfo)
diff --git a/tww/templates/dt_tr.html b/tww/templates/dt_tr.html
index af2275b..1ee2cd8 100644
--- a/tww/templates/dt_tr.html
+++ b/tww/templates/dt_tr.html
@@ -1,12 +1,12 @@
+ value="{{ dt.iso8601_full }}" style="width: 320px;"/>
+ value="{{ dt.iso8601_date }}"/>
+ value="{{ dt.iso8601_time }}"/>
+ value="{{ dt.tz_offset }}" size="8"/>