Problem with timedelta to duration conversion
Brought to you by:
pabigot
When using a timedelta with less than a minute:
d = duration( timedelta(hours=0, seconds = 3, minutes = 0) )
print d
Displays:
3:00:03
Changing L.252 of pyxb.binding.datatypes.duration from:
if (0 != (rem_time % 1)):
data['microseconds'] = types.IntType(1000000 * (rem_time % 1))
rem_time = rem_time // 1
if 60 <= rem_time:
data['seconds'] = rem_time % 60
rem_time = data['minutes'] + (rem_time // 60)
if 60 <= rem_time:
data['minutes'] = rem_time % 60
rem_time = data['hours'] + (rem_time // 60)
To:
if (0 != (rem_time % 1)):
data['microseconds'] = types.IntType(1000000 * (rem_time % 1))
rem_time = rem_time // 1
data['seconds'] = rem_time % 60
rem_time = data['minutes'] + (rem_time // 60)
data['minutes'] = rem_time % 60
rem_time = data['hours'] + (rem_time // 60)
data['hours'] = rem_time % 24
Seems to solve the problem.
Wow, I must have really been out of it when doing that module. Fixed, along with several related issues, patches available in branch "next".
commit ce06a15901f043c9e51de62d90f31f7f8194f093
Author: Peter A. Bigot <bigotp@…>
Date: Mon Jan 16 21:55:25 2012 -0600
commit e895e28cc8a82b6846f0445fbd0004211362f66c
Author: Peter A. Bigot <bigotp@…>
Date: Mon Jan 16 21:48:39 2012 -0600
commit cee70bccb8736c5ec32dde15c64e842a51933412
Author: Peter A. Bigot <bigotp@…>
Date: Mon Jan 16 21:48:27 2012 -0600
commit da14d3cbe93c302fe2929c1929daf82a5829e09a
Author: Peter A. Bigot <bigotp@…>
Date: Mon Jan 16 21:35:52 2012 -0600
And thanks for bringing it to my attention (with fix).
You're welcome, thanks for the quick commit and for all your work on pyxb.