@@ -44,6 +44,8 @@ class Type(str, Enum):
4444    PATHLIB_PATH  =  "pathlib:path" 
4545    DT_DATE  =  "dt:date" 
4646    DT_DATETIME  =  "dt:datetime" 
47+     DT_TIME  =  "dt:time" 
48+     DT_TIMEDELTA  =  "dt:timedelta" 
4749
4850    def  __str__ (self ):
4951        return  self .value 
@@ -142,6 +144,19 @@ def json_default(o):
142144            TYPE_KEY : Type .DT_DATE ,
143145            "date" : o .isoformat (),
144146        }
147+     if  isinstance (o , dt .time ):
148+         return  {
149+             TYPE_KEY : Type .DT_TIME ,
150+             "time" : o .isoformat (),
151+         }
152+     if  isinstance (o , dt .timedelta ):
153+         return  {
154+             TYPE_KEY : Type .DT_TIMEDELTA ,
155+             "days" : o .days ,
156+             "seconds" : o .seconds ,
157+             "microseconds" : o .microseconds ,
158+             # docstring of timedelta says: Representation: (days, seconds, microseconds). 
159+         }
145160    if  get_origin (o ) is  not   None :
146161        # must be GenericAlias 
147162        # somehow isinstance(o, GenericAlias) did not work reliably 
@@ -270,6 +285,10 @@ def get_stage(name: str | None):
270285        return  Path (d ["path" ])
271286    if  type_  ==  Type .DT_DATE :
272287        return  dt .date .fromisoformat (d ["date" ])
288+     if  type_  ==  Type .DT_TIME :
289+         return  dt .time .fromisoformat (d ["time" ])
290+     if  type_  ==  Type .DT_TIMEDELTA :
291+         return  dt .timedelta (d ["days" ], d ["seconds" ], d ["microseconds" ])
273292    if  type_  ==  Type .DT_DATETIME :
274293        return  dt .datetime .fromisoformat (d ["datetime" ])
275294    if  type_  ==  Type .DATA_CLASS :
0 commit comments