@@ -139,12 +139,12 @@ class time(pdt.time):
139139 def __new__ (cls ,
140140 hour = 0 , minute = 0 ,
141141 second = 0 , microsecond = 0 ,
142- tzinfo = None , fold = 0 ):
142+ tzinfo = None , ** kwargs ):
143143 # round down to zero seconds and microseconds
144144 return pdt .time .__new__ (cls ,
145145 hour = hour , minute = minute ,
146146 second = 0 , microsecond = 0 ,
147- tzinfo = None , fold = fold )
147+ tzinfo = None , ** kwargs )
148148
149149 @classmethod
150150 def _extract_time (cls , match , h = "hour" , m = "minute" ):
@@ -220,12 +220,12 @@ class datetime(pdt.datetime):
220220 def __new__ (cls , year , month , day ,
221221 hour = 0 , minute = 0 ,
222222 second = 0 , microsecond = 0 ,
223- tzinfo = None , * , fold = 0 ):
223+ tzinfo = None , ** kwargs ):
224224 # round down to zero seconds and microseconds
225225 return pdt .datetime .__new__ (cls , year , month , day ,
226226 hour = hour , minute = minute ,
227227 second = 0 , microsecond = 0 ,
228- tzinfo = None , fold = fold )
228+ tzinfo = None , ** kwargs )
229229
230230 def __add__ (self , other ):
231231 # python datetime.__add__ was not type stable prior to 3.8
@@ -234,11 +234,13 @@ def __add__(self, other):
234234 # similar to https://stackoverflow.com/q/51966126/3565696
235235 # __getnewargs_ex__ did not work, brute force required
236236 def __deepcopy__ (self , memo ):
237+ kwargs = {}
238+ if (hasattr (self , 'fold' )):
239+ kwargs ['fold' ] = self .fold
237240 return datetime (self .year , self .month , self .day ,
238241 self .hour , self .minute ,
239242 self .second , self .microsecond ,
240- self .tzinfo , fold = self .fold )
241-
243+ self .tzinfo , ** kwargs )
242244 __radd__ = __add__
243245
244246 def __sub__ (self , other ):
@@ -327,10 +329,13 @@ def from_day_time(cls, d: hday, t: time):
327329 @classmethod
328330 def from_pdt (cls , t ):
329331 """Convert python datetime to hamster datetime."""
332+ kwargs = {}
333+ if (hasattr (t , 'fold' )):
334+ kwargs ['fold' ] = t .fold
330335 return cls (t .year , t .month , t .day ,
331336 t .hour , t .minute ,
332337 t .second , t .microsecond ,
333- t .tzinfo , fold = t . fold )
338+ t .tzinfo , ** kwargs )
334339
335340 @classmethod
336341 def now (cls ):
@@ -392,10 +397,13 @@ def pattern(cls, n=None):
392397
393398 def to_pdt (self ):
394399 """Convert to python datetime."""
400+ kwargs = {}
401+ if (hasattr (self , 'fold' )):
402+ kwargs ['fold' ] = self .fold
395403 return pdt .datetime (self .year , self .month , self .day ,
396404 self .hour , self .minute ,
397405 self .second , self .microsecond ,
398- self .tzinfo , fold = self . fold )
406+ self .tzinfo , ** kwargs )
399407
400408
401409# outside class; need the class to be defined first
0 commit comments