diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py index 825ab45bdc..35ef9ee6a8 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import datetime import ifcopenshell import ifcopenshell.util.element import ifcopenshell.util.pset @@ -446,6 +447,11 @@ class Usecase: return "IfcBoolean" elif isinstance(new_value, int): return "IfcInteger" + # @nb datetime is also a date, so needs to be checked first + elif isinstance(new_value, datetime.datetime): + return "IfcDateTime" + elif isinstance(new_value, datetime.date): + return "IfcDate" def cast_value_to_primary_measure_type(self, value, primary_measure_type): type_str = self.file.create_entity(primary_measure_type).attribute_type(0) @@ -464,6 +470,8 @@ class Usecase: return [float(i) for i in value] elif type_str == "AGGREGATE OF INT": return [int(i) for i in value] + elif isinstance(value, (datetime.date, datetime.datetime)): + return value.isoformat() return type_fn(value) @staticmethod