Commits

Jean-Tiare Le Bigot committed 23454ac

fix bug #13 'Z timezone parsing'; thx Merwok

Comments (0)

Files changed (2)

dynamodb_mapper/model.py

         # 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'
+            value = value[:-1] + '+00:00'
         return datetime.strptime(
             value, "%Y-%m-%dT%H:%M:%S.%f+00:00").replace(tzinfo=utc_tz)
 

dynamodb_mapper/tests/test_model.py

 
     def test_dynamodb_to_python_datetime(self):
         self.assertEquals(
-            datetime.datetime(2012, 05, 31, 12, 0, 0, tzinfo=utc_tz),
+            datetime.datetime(2012, 05, 31, 12, 0, 42, tzinfo=utc_tz),
             _dynamodb_to_python(datetime.datetime,
-                                "2012-05-31T12:00:00.000000+00:00"))
+                                "2012-05-31T12:00:00.000042+00:00"))
         self.assertEquals(
-            datetime.datetime(2010, 11, 1, 4, 0, 0, tzinfo=utc_tz),
+            datetime.datetime(2010, 11, 1, 4, 0, 13, tzinfo=utc_tz),
             _dynamodb_to_python(datetime.datetime,
-                                "2010-11-01T04:00:00.000000Z"))
+                                "2010-11-01T04:00:00.000013Z"))
 
     def test_dynamodb_to_python_default(self):
         self.assertIsNone(_dynamodb_to_python(datetime.datetime, None))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.