Commits

Éric Araujo  committed 3e6e628

* Add support for datetimes using "Z" as timezone info

  • Participants
  • Parent commits a7f082d

Comments (0)

Files changed (2)

File dynamodb_mapper/model.py

         # strptime doesn't support timezone parsing (%z flag), so we're forcing
         # the strings in the database to be UTC (+00:00) for now.
         # TODO Handle arbitrary timezones (with manual parsing).
+        if value.endswith('Z'):
+            value = value[:-2] + '+00:00'
         return datetime.datetime.strptime(
             value, "%Y-%m-%dT%H:%M:%S.%f+00:00").replace(tzinfo=utc_tz)
 

File dynamodb_mapper/tests/test_model.py

             datetime.datetime(2012, 05, 31, 12, 0, 0, tzinfo=utc_tz),
             _dynamodb_to_python(datetime.datetime,
                                 "2012-05-31T12:00:00.000000+00:00"))
+        self.assertEquals(
+            datetime.datetime(2010, 11, 1, 4, 0, 0, tzinfo=utc_tz),
+            _dynamodb_to_python(datetime.datetime,
+                                "2010-11-01T04:00:00.000000Z"))
 
     def test_dynamodb_to_python_datetime_notz(self):
         # Timezone info is mandatory