mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
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.
This commit is contained in:
committed by
Thomas Krijnen
parent
34da3950e3
commit
913f9f2262
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user