Selaa lähdekoodia

fromisoformat is too new

Maarten van den Berg 6 vuotta sitten
vanhempi
commit
4010b5ea10
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      piket_client/model.py

+ 4 - 1
piket_client/model.py

@@ -260,12 +260,15 @@ class Consumption(NamedTuple):
260 260
     @classmethod
261 261
     def from_dict(cls, data: dict) -> "Consumption":
262 262
         """ Reconstruct a Consumption from a dict. """
263
+        datetime_format = '%Y-%m-%dT%H:%M:%S.%f'
264
+        # 2018-08-31T17:30:47.871521
263 265
         return cls(
264 266
             consumption_id=data["consumption_id"],
265 267
             person_id=data["person_id"],
266 268
             consumption_type_id=data["consumption_type_id"],
267 269
             settlement_id=data["settlement_id"],
268
-            created_at=datetime.datetime.fromisoformat(data["created_at"]),
270
+            created_at=datetime.datetime.strptime(data["created_at"],
271
+                datetime_format),
269 272
             reversed=data["reversed"],
270 273
         )
271 274