From 98cba98f7db68c41010937d4e404d59d34fe2c27 Mon Sep 17 00:00:00 2001 From: Bruno Postle Date: Thu, 23 Nov 2023 21:16:24 +0000 Subject: [PATCH] fix python 3.12 utcnow() deprecation warning Warning is: /usr/lib64/python3.12/site-packages/ifcopenshell/api/project/create_file.py:61: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). --- src/blenderbim/blenderbim/bim/export_ifc.py | 2 +- src/ifcopenshell-python/ifcopenshell/api/project/create_file.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/export_ifc.py b/src/blenderbim/blenderbim/bim/export_ifc.py index 77ed7eaa50..aee40eb7b7 100644 --- a/src/blenderbim/blenderbim/bim/export_ifc.py +++ b/src/blenderbim/blenderbim/bim/export_ifc.py @@ -74,7 +74,7 @@ class IfcExporter: def set_header(self): self.file.wrapped_data.header.file_name.name = os.path.basename(self.ifc_export_settings.output_file) self.file.wrapped_data.header.file_name.time_stamp = ( - datetime.datetime.utcnow() + datetime.datetime.now(datetime.UTC) .replace(tzinfo=datetime.timezone.utc) .astimezone() .replace(microsecond=0) diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/create_file.py b/src/ifcopenshell-python/ifcopenshell/api/project/create_file.py index 45ce3d6c6a..988d3f72d4 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/project/create_file.py +++ b/src/ifcopenshell-python/ifcopenshell/api/project/create_file.py @@ -58,7 +58,7 @@ class Usecase: self.file = ifcopenshell.file(schema=self.settings["version"]) self.file.wrapped_data.header.file_name.name = "/dev/null" # Hehehe self.file.wrapped_data.header.file_name.time_stamp = ( - datetime.datetime.utcnow() + datetime.datetime.now(datetime.UTC) .replace(tzinfo=datetime.timezone.utc) .astimezone() .replace(microsecond=0)