mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
typing
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user