openyou/libomron

Fix for problem in store.py, Please examine

Opened this issue · 1 comments

When using python I've got the following problem

/opt/omron/usr/local/python/omron/store.py", line 7, in ymdhms2seconds
t = time.strptime("%d %d %d %d %d %d"%(YY,MM,DD,hh,mm,ss),format)
File "/usr/lib/python2.6/_strptime.py", line 454, in _strptime_time
return _strptime(data_string, format)[0]
File "/usr/lib/python2.6/_strptime.py", line 325, in _strptime
(data_string, format))
ValueError: time data '9 1 14 11 21 59' does not match format '%y %m %d %H %M %S'

line 6 and 7 in store.py are
6 format = "%y %m %d %H %M %S"

I fixed it by adding 02 for each %d so line 7 became

7 t = time.strptime("%02d %02d %02d %02d %02d %02d"%(YY,MM,DD,hh,mm,ss),format)

so instead year 9 its 09 and month 1 its 01, looks like %y and %m specs always requres 2 digits and not one

line 7 before fix was
7 t = time.strptime("%d %d %d %d %d %d"%(YY,MM,DD,hh,mm,ss),format)