From 3368a65935bcf89771a832e99a6a132e31de9c21 Mon Sep 17 00:00:00 2001 From: Alkid Date: Wed, 13 Nov 2024 16:36:18 +0100 Subject: [PATCH] fixes --- owlapy/owl_literal.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/owlapy/owl_literal.py b/owlapy/owl_literal.py index 094ba37c..d6ffb5bb 100644 --- a/owlapy/owl_literal.py +++ b/owlapy/owl_literal.py @@ -734,14 +734,20 @@ class _OWLDateAndTimeLiteralInterface(_OWLLiteralBasicsInterface): def __init__(self, value, type_=None): if isinstance(value, datetime) or type_ is DateTimeOWLDatatype: - value = value.replace("Z", "+00:00") if isinstance(value, str) and value[-1] == "Z" else value - value = datetime.fromisoformat(value) + if isinstance(value, str): + if value[-1] == "Z": + value = value.replace("Z", "+00:00") + value = datetime.fromisoformat(value) if isinstance(value, date) or type_ is DateOWLDatatype: - value = value.replace("Z", "+00:00") if isinstance(value, str) and value[-1] == "Z" else value - value = date.fromisoformat(value) + if isinstance(value, str): + if value[-1] == "Z": + value = value.replace("Z", "+00:00") + value = date.fromisoformat(value) if isinstance(value, time) or type_ is TimeOWLDatatype: - value = value.replace("Z", "+00:00") if isinstance(value, str) and value[-1] == "Z" else value - value = time.fromisoformat(value) + if isinstance(value, str): + if value[-1] == "Z": + value = value.replace("Z", "+00:00") + value = time.fromisoformat(value) if isinstance(value, Timedelta) or type_ is DurationOWLDatatype: value = Timedelta(value) if isinstance(value, str) else value assert type(value) in [datetime, date, time, Timedelta]