mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-01-23 02:14:04 +00:00
Add time_fromisoformat
This commit is contained in:
parent
2ac382f856
commit
828ffb1d3c
1 changed files with 10 additions and 0 deletions
|
|
@ -80,6 +80,16 @@ else:
|
|||
return result
|
||||
|
||||
|
||||
if sys.version_info[:2] >= (3, 7):
|
||||
time_fromisoformat = datetime_module.time.fromisoformat
|
||||
else:
|
||||
def time_fromisoformat(isoformat_str):
|
||||
hour, minute, second, microsecond = map(
|
||||
int,
|
||||
isoformat_str.replace('.', ':').split(':'))
|
||||
return datetime_module.time(hour, minute, second, microsecond)
|
||||
|
||||
|
||||
def timedelta_isoformat(timedelta, timespec='microseconds'):
|
||||
assert isinstance(timedelta, datetime_module.timedelta)
|
||||
if timespec != 'microseconds':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue