mirror of
https://opendev.org/x/pyghmi
synced 2025-01-15 04:07:48 +00:00
Improve date parsing performance
strptime attempts are moderately expensive. Detect one common scenario using quicker mechanisms. Change-Id: Id9346678f7def12981417da4d2e6374f457967c5
This commit is contained in:
parent
79e1df669d
commit
06e2723fe0
@ -20,8 +20,9 @@ def parse_time(timeval):
|
||||
if timeval is None:
|
||||
return None
|
||||
try:
|
||||
retval = datetime.strptime(timeval, '%Y-%m-%dT%H:%M:%SZ')
|
||||
return retval.replace(tzinfo=tz.tzutc())
|
||||
if '+' not in timeval and len(timeval.split('-')) <= 3:
|
||||
retval = datetime.strptime(timeval, '%Y-%m-%dT%H:%M:%SZ')
|
||||
return retval.replace(tzinfo=tz.tzutc())
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user