Merge pull request #1231 from paddatrapper/fix/python-valueerror
Allow schedule times without microseconds in api_client
This commit is contained in:
commit
d5781d198c
|
@ -198,5 +198,8 @@ def fromisoformat(time_string):
|
||||||
only added in Python 3.7. Until LibreTime drops Python 3.6 support, this
|
only added in Python 3.7. Until LibreTime drops Python 3.6 support, this
|
||||||
wrapper uses the old way of doing it.
|
wrapper uses the old way of doing it.
|
||||||
"""
|
"""
|
||||||
datetime_obj = datetime.datetime.strptime(time_string, "%H:%M:%S.%f")
|
try:
|
||||||
|
datetime_obj = datetime.datetime.strptime(time_string, "%H:%M:%S.%f")
|
||||||
|
except ValueError:
|
||||||
|
datetime_obj = datetime.datetime.strptime(time_string, "%H:%M:%S")
|
||||||
return datetime_obj.time()
|
return datetime_obj.time()
|
||||||
|
|
|
@ -51,6 +51,7 @@ def test_get_protocol_force_https(payload, use_config, values, expected):
|
||||||
[
|
[
|
||||||
("00:00:00.500000", datetime.time(microsecond=500000)),
|
("00:00:00.500000", datetime.time(microsecond=500000)),
|
||||||
("00:04:30.092540", datetime.time(minute=4, second=30, microsecond=92540)),
|
("00:04:30.092540", datetime.time(minute=4, second=30, microsecond=92540)),
|
||||||
|
("00:04:30", datetime.time(minute=4, second=30)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_fromisoformat(payload, expected):
|
def test_fromisoformat(payload, expected):
|
||||||
|
|
Loading…
Reference in New Issue