Commit d56fcf2c authored by Jérome Perrin's avatar Jérome Perrin

tidrange: don't parse dates that looks like TID

Parsing dates is really slow.
On the other hand, this optimization might cause error if entering a
date looking like a TID, but I'm not sure there is.
parent 78455126
...@@ -74,6 +74,16 @@ def tid_from_date(date_string): ...@@ -74,6 +74,16 @@ def tid_from_date(date_string):
""" """
if not date_string: if not date_string:
return date_string return date_string
# If it "looks like a TID", don't try to parse it as date,
# because parsing as date is slow.
if len(date_string) == 16:
try:
fromhex(date_string)
return date_string
except TypeError:
pass
date = dateparser.parse( date = dateparser.parse(
date_string, date_string,
settings={ settings={
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment