@@ -231,7 +231,7 @@ class DateTime(CompositeType):
231231 and last four bytes are offset from the beginning of the month in minutes
232232 """
233233
234- def __init__ (self , year = 0 , month = 0 , minutes = 0 ):
234+ def __init__ (self , year = 0 , month = 1 , minutes = 0 ):
235235 CompositeType .__init__ (self )
236236 self .year = Year2k (year - PLUGWISE_EPOCH , 2 )
237237 self .month = Int (month , 2 , False )
@@ -241,16 +241,21 @@ def __init__(self, year=0, month=0, minutes=0):
241241 def deserialize (self , val ):
242242 CompositeType .deserialize (self , val )
243243 minutes = self .minutes .value
244- if minutes == 65535 :
244+ if minutes == 0 :
245+ self .value = datetime .datetime (PLUGWISE_EPOCH , 1 , 1 , 0 , 0 )
246+ elif minutes == 65535 :
245247 self .value = None
246248 else :
247249 hours = minutes // 60
248250 days = hours // 24
249251 hours -= days * 24
250252 minutes -= (days * 24 * 60 ) + (hours * 60 )
251- self .value = datetime .datetime (
252- self .year .value , self .month .value , days + 1 , hours , minutes
253- )
253+ try :
254+ self .value = datetime .datetime (
255+ self .year .value , self .month .value , days + 1 , hours , minutes
256+ )
257+ except :
258+ self .value = None
254259
255260
256261class Time (CompositeType ):
0 commit comments