mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
See #2783. Don't show 0 durations for clarity.
This commit is contained in:
@@ -81,13 +81,15 @@ def readable_ifc_duration(duration):
|
||||
for designator in ("Y", "M", "W", "D"):
|
||||
if designator in period_duration:
|
||||
value, period_duration = period_duration.split(designator)
|
||||
result.append(f"{value}{designator}")
|
||||
if int(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)
|
||||
result.append(f"{value}{designator.lower()}")
|
||||
if int(value):
|
||||
result.append(f"{value}{designator.lower()}")
|
||||
return " ".join(result)
|
||||
|
||||
|
||||
|
||||
@@ -23,5 +23,6 @@ import ifcopenshell.util.date as subject
|
||||
|
||||
class TestReadableIFCDuration():
|
||||
def test_run(self):
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user