This commit is contained in:
Andrej730
2024-05-13 12:27:53 +05:00
parent c3bfd7354f
commit ebd03e9290
56 changed files with 244 additions and 127 deletions
@@ -19,6 +19,7 @@
import datetime
from re import findall
from dateutil import parser
from typing import Literal, Union, Any
try:
import isodate
@@ -104,7 +105,18 @@ def readable_ifc_duration(string):
return final_string
def datetime2ifc(dt, ifc_type):
def datetime2ifc(
dt: Union[datetime.date, str],
ifc_type: Literal[
"IfcDuration",
"IfcTimeStamp",
"IfcDateTime",
"IfcDate",
"IfcTime",
"IfcCalendarDate",
"IfcLocalTime",
],
) -> Union[int, str, dict[str, Any]]:
if isinstance(dt, str):
if ifc_type == "IfcDuration":
return dt
@@ -145,6 +157,7 @@ def datetime2ifc(dt, ifc_type):
"MinuteComponent": dt.minute,
"SecondComponent": dt.second,
}
raise TypeError(f"Unsupported ifc_type for conversion from datetime.datetime = {ifc_type}.")
def string_to_date(string):