#206 dateTime.aslocal does not work for non UTC datetimes

PyXB 1.2.3
closed
None
fixed
Binding model
trivial
PyXB 1.2.2
defect
2013-09-11
2013-09-02
jmaroto
No

Whenever a pyxb.binding.datatypes.dateTime instance contains a timezone different from UTC, aslocal return an incorrect date.

Consider the following (with local timezone = +02:00):

>>> import pyxb.binding
>>> pyxb.PreserveInputTimeZone(True)
True
>>> print pyxb.binding.datatypes.dateTime("2013-08-30T11:56:45+04:00").aslocal()
2013-08-30 13:56:45+02:00

Correct date should be 2013-08-30 09:56:45+02:00

A simple check in aslocal method before replacing tzinfo should do the trick.

Discussion

  • Peter A. Bigot

    Peter A. Bigot - 2013-09-02
    • status changed from new to closed
    • resolution set to fixed

    Thanks for the report. Fixed in next branch per this commit:

    commit 46d6e2a4a6c407ae04a13860e68bdf9f8262ecbc
    Author: Peter A. Bigot <pab@pabigot.com>
    Date:   Mon Sep 2 11:49:59 2013 -0500
    
        trac/206: dateTime.aslocal does not work for non UTC datetimes
    
        Preserve any existing tzinfo when converting to a local time, with UTC
        enforced only for naive times.
    
     
  • Peter A. Bigot

    Peter A. Bigot - 2013-09-11
    • milestone set to PyXB 1.2.3
     

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

Sign up for the SourceForge newsletter:





No, thanks