From 1f9a0a53bbbba4c982b785a5744fa677b4bbc5a4 Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Thu, 30 Jul 2026 12:56:18 +0300 Subject: [PATCH] ifcopenshell.template: fix timestring ignoring an explicit timestamp of 0 create(timestamp=0) computed the FILE_NAME timestring with `d.get("timestamp") or time.time()`, which treats 0 (a legitimate epoch timestamp) as unset because 0 is falsy. The header ended up with the current wall-clock time in FILE_NAME while IFCOWNERHISTORY correctly stored CreationDate=0, an inconsistent pair of dates in the same file. Switched to an explicit None check so an explicit timestamp of 0 is honoured the same way any other explicit timestamp is. Generated with the assistance of an AI coding tool. --- src/ifcopenshell-python/ifcopenshell/template.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/template.py b/src/ifcopenshell-python/ifcopenshell/template.py index bd58d0fdef..ed020e7cf7 100644 --- a/src/ifcopenshell-python/ifcopenshell/template.py +++ b/src/ifcopenshell-python/ifcopenshell/template.py @@ -64,7 +64,10 @@ DEFAULTS = { "project_globalid": lambda d: compress(uuid.uuid4().hex), "schema_identifier": lambda d: "IFC4", "timestamp": lambda d: int(time.time()), - "timestring": lambda d: time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(d.get("timestamp") or time.time())), + "timestring": lambda d: time.strftime( + "%Y-%m-%dT%H:%M:%S", + time.gmtime(d["timestamp"] if d.get("timestamp") is not None else time.time()), + ), "mvd": lambda d: ( "ReferenceView_V1.2" if d.get("schema_identifier") == "IFC4"