Support times specified as ISO strings too in date utils, not just datetimes.

This commit is contained in:
Dion Moult
2023-02-02 23:01:49 +11:00
parent 7c275a99a2
commit be26a77ecb
2 changed files with 5 additions and 2 deletions
@@ -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")
@@ -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)