#115 Problem with timedelta to duration conversion

PyXB 1.1.4
closed
None
fixed
Binding model
minor
PyXB 1.1.3
defect
2012-01-19
2012-01-16
Robin V.
No

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.

Discussion

  • Peter A. Bigot

    Peter A. Bigot - 2012-01-17
    • status changed from new to closed
    • resolution set to fixed

    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

    trac/115: Problem with timedelta to duration conversion

    commit e895e28cc8a82b6846f0445fbd0004211362f66c
    Author: Peter A. Bigot <bigotp@…>
    Date: Mon Jan 16 21:48:39 2012 -0600

    xsd.datetime: avoid mutating source internal data structure

    commit cee70bccb8736c5ec32dde15c64e842a51933412
    Author: Peter A. Bigot <bigotp@…>
    Date: Mon Jan 16 21:48:27 2012 -0600

    xsd.datetime: check for absent/invalid constructor arg

    commit da14d3cbe93c302fe2929c1929daf82a5829e09a
    Author: Peter A. Bigot <bigotp@…>
    Date: Mon Jan 16 21:35:52 2012 -0600

    xsd.datetime: fix boundary case error with negative whole-day durations

     
  • Peter A. Bigot

    Peter A. Bigot - 2012-01-17

    And thanks for bringing it to my attention (with fix).

     
  • Robin V.

    Robin V. - 2012-01-19

    You're welcome, thanks for the quick commit and for all your work on pyxb.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks