[utils] Improve parse_duration

Authored by: bashonly
This commit is contained in:
bashonly 2023-07-20 08:40:31 -05:00
parent 75dc8e673b
commit af86873218
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0
2 changed files with 3 additions and 1 deletions

View File

@ -655,6 +655,8 @@ def test_parse_duration(self):
self.assertEqual(parse_duration('P0Y0M0DT0H4M20.880S'), 260.88)
self.assertEqual(parse_duration('01:02:03:050'), 3723.05)
self.assertEqual(parse_duration('103:050'), 103.05)
self.assertEqual(parse_duration('1HR 3MIN'), 3780)
self.assertEqual(parse_duration('2hrs 3mins'), 7380)
def test_fix_xml_ampersands(self):
self.assertEqual(

View File

@ -2021,7 +2021,7 @@ def parse_duration(s):
)?
T)?
(?:
(?P<hours>[0-9]+)\s*h(?:ours?)?,?\s*
(?P<hours>[0-9]+)\s*h(?:(?:ou)?rs?)?,?\s*
)?
(?:
(?P<mins>[0-9]+)\s*m(?:in(?:ute)?s?)?,?\s*