mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Use indices instead of WorkTimeDatesInterface
Checking start/end dates are done very, very often in date calculations (often looping through every day in a date range). So I'd prefer more opaque code but less overhead.
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.util.date
|
||||
from ifcopenshell.util.data import WorkTimeDatesInterface
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -55,10 +54,12 @@ class Usecase:
|
||||
self.settings = {"work_time": work_time, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
work_time_dates = WorkTimeDatesInterface(self.settings["work_time"])
|
||||
for name, value in self.settings["attributes"].items():
|
||||
if name in ("Start", "Finish", "StartDate", "FinishDate"):
|
||||
if name in ("Start", "StartDate"):
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDate")
|
||||
setattr(work_time_dates, name, value)
|
||||
self.settings["work_time"][4] = value
|
||||
elif name in ("Finish", "FinishDate"):
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDate")
|
||||
self.settings["work_time"][5] = value
|
||||
else:
|
||||
setattr(self.settings["work_time"], name, value)
|
||||
|
||||
Reference in New Issue
Block a user