add timezone support to DateTime

Bug #280708 reported by Markus Korn on 2008-10-09
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Storm
Undecided
Unassigned

Bug Description

storing of datetime objects with timezone information does not work, as an example see the attached script which fails with an ValueError:

python test_db.py
Traceback (most recent call last):
  File "test_db.py", line 49, in <module>
    print [i.date for i in db.store.find(Dates)]
  File "/usr/lib/python2.5/site-packages/storm/store.py", line 917, in __iter__
    yield self._load_objects(result, values)
  File "/usr/lib/python2.5/site-packages/storm/store.py", line 910, in _load_objects
    return self._store._load_objects(self._cls_spec_info, result, values)
  File "/usr/lib/python2.5/site-packages/storm/store.py", line 608, in _load_objects
    return self._load_object(cls_spec_info, result, values)
  File "/usr/lib/python2.5/site-packages/storm/store.py", line 666, in _load_object
    self._set_values(obj_info, cls_info.columns, result, values)
  File "/usr/lib/python2.5/site-packages/storm/store.py", line 721, in _set_values
    result.set_variable(variable, value)
  File "/usr/lib/python2.5/site-packages/storm/databases/sqlite.py", line 83, in set_variable
    variable.set(value, from_db=True)
  File "/usr/lib/python2.5/site-packages/storm/variables.py", line 192, in set
    new_value = self.parse_set(value, from_db)
  File "/usr/lib/python2.5/site-packages/storm/variables.py", line 391, in parse_set
    _parse_time(time_str)))
  File "/usr/lib/python2.5/site-packages/storm/variables.py", line 578, in _parse_time
    raise ValueError("Unknown time format: %r" % time_str)
ValueError: Unknown time format: u'12:30:40+00:00'

Thanks,
Markus

Markus Korn (thekorn) wrote :
Markus Korn (thekorn) wrote :

I worked around it by subclassing DateTime, maybe this helps you fixing this issue

Barry Warsaw (barry) wrote :

I'm hitting this in Mailman 3 now because I'm creating all my datetime objects with a UTC timezone. This adds the +00:00 suffix onto the str format, breaking DateTime as you see above. At the very least, UTC timezones should be supported directly.

Barry Warsaw (barry) wrote :

Markus, can you post your subclass? It would be nice not to duplicate the effort with subtle differences.

Aurélien Bompard (abompard) wrote :

Barry, the subclass is in the test_db.py file Markus posted on comment #2.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers