From be26a77ecb4ce5d4105d45d737456341671ecd6b Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 2 Feb 2023 23:01:49 +1100 Subject: [PATCH] Support times specified as ISO strings too in date utils, not just datetimes. --- .../ifcopenshell/api/sequence/add_work_calendar.py | 2 +- src/ifcopenshell-python/ifcopenshell/util/date.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_calendar.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_calendar.py index 0767ceb51c..8823c3f215 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_calendar.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_calendar.py @@ -67,7 +67,7 @@ class Usecase: parent=work_time, recurrence_type="WEEKLY") # State that we work from weekdays 1 to 5 (i.e. Monday to Friday), 9am to 5pm - ifcopenshell.api.run("sequence.edit_recurrence_pattern", mdoel, + ifcopenshell.api.run("sequence.edit_recurrence_pattern", model, recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]}) ifcopenshell.api.run("sequence.add_time_period", model, recurrence_pattern=pattern, start_time="09:00", end_time="17:00") diff --git a/src/ifcopenshell-python/ifcopenshell/util/date.py b/src/ifcopenshell-python/ifcopenshell/util/date.py index 8d41850a98..94f87d848c 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/date.py +++ b/src/ifcopenshell-python/ifcopenshell/util/date.py @@ -75,7 +75,10 @@ def datetime2ifc(dt, ifc_type): if isinstance(dt, str): if ifc_type == "IfcDuration": return dt - dt = datetime.datetime.fromisoformat(dt) + try: + dt = datetime.datetime.fromisoformat(dt) + except: + dt = datetime.time.fromisoformat(dt) if ifc_type == "IfcDuration": return isodate.duration_isoformat(dt)