Use isodate to parse iso durations #2783

Related #6585

Co-Authored-By: sboddy <12862430+sboddy@users.noreply.github.com>
This commit is contained in:
Andrej730
2025-04-21 12:35:00 +05:00
parent 311f9b96e7
commit f8ad05cb54
2 changed files with 47 additions and 27 deletions
@@ -0,0 +1,27 @@
# IfcOpenShell - IFC toolkit and geometry engine
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of IfcOpenShell.
#
# IfcOpenShell is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# IfcOpenShell is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import pytest
import test.bootstrap
import ifcopenshell.util.date as subject
class TestIsoDuration:
def test_run(self):
assert subject.readable_ifc_duration("P2Y3M1W4DT5H45M30S") == "2 y 3 m 1 w 4 d 5 h 45 m 30 s"
assert subject.readable_ifc_duration("P2Y3MT30S") == "2 y 3 m 30 s"