mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
@@ -93,14 +93,14 @@ def readable_ifc_duration(duration: str) -> str:
|
||||
for designator in ("Y", "M", "W", "D"):
|
||||
if designator in period_duration:
|
||||
value, period_duration = period_duration.split(designator)
|
||||
if int(value):
|
||||
if float(value):
|
||||
result.append(f"{value}{designator}")
|
||||
|
||||
if time_duration:
|
||||
for designator in ("H", "M", "S"):
|
||||
if designator in time_duration:
|
||||
value, time_duration = time_duration.split(designator)
|
||||
if int(value):
|
||||
if float(value):
|
||||
result.append(f"{value}{designator.lower()}")
|
||||
return " ".join(result)
|
||||
|
||||
|
||||
@@ -26,3 +26,7 @@ class TestReadableIFCDuration:
|
||||
assert subject.readable_ifc_duration("P0Y0M1DT16H0M0S") == "1D 16h"
|
||||
assert subject.readable_ifc_duration("P2Y3M1W4DT5H45M30S") == "2Y 3M 1W 4D 5h 45m 30s"
|
||||
assert subject.readable_ifc_duration("PT40H") == "40h"
|
||||
|
||||
# Float values.
|
||||
assert subject.readable_ifc_duration("P2.5D") == "2.5D"
|
||||
assert subject.readable_ifc_duration("PT1.5H") == "1.5h"
|
||||
|
||||
Reference in New Issue
Block a user