diff --git a/server/json_encoder.py b/server/json_encoder.py index dee3c53..b5eb05a 100644 --- a/server/json_encoder.py +++ b/server/json_encoder.py @@ -4,8 +4,8 @@ def _encode_time(time): - """Encodes time in YYYYMMDDTHHMMSSZ format (assumes UTC time zone).""" - return datetime.datetime.strftime(time, '%Y%m%dT%H%M%SZ') + """Encodes time in YYYYMMDDTHHMMZ format (assumes UTC time zone).""" + return datetime.datetime.strftime(time, '%Y%m%dT%H%MZ') class Encoder(simplejson.JSONEncoder): diff --git a/tests/test_json_encoder.py b/tests/test_json_encoder.py index 83f7f90..c08dd08 100644 --- a/tests/test_json_encoder.py +++ b/tests/test_json_encoder.py @@ -22,60 +22,60 @@ def test_encodes_records_correctly(self): self.assertJsonEqual( """ { - "timestamp": "20170319T150123Z", + "timestamp": "20170319T1501Z", "soil_moisture": 305 } """.strip(), self.encoder.encode( db_store.SoilMoistureRecord( timestamp=datetime.datetime( - 2017, 3, 19, 15, 1, 23, 924000, tzinfo=pytz.utc), + 2017, 3, 19, 15, 1, tzinfo=pytz.utc), soil_moisture=305))) self.assertJsonEqual( """ { - "timestamp": "20170319T150123Z", + "timestamp": "20170319T1501Z", "ambient_light": 87.3 } """.strip(), self.encoder.encode( db_store.AmbientLightRecord( timestamp=datetime.datetime( - 2017, 3, 19, 15, 1, 23, 924000, tzinfo=pytz.utc), + 2017, 3, 19, 15, 1, tzinfo=pytz.utc), ambient_light=87.3))) self.assertJsonEqual( """ { - "timestamp": "20170319T150123Z", + "timestamp": "20170319T1501Z", "humidity": 21.5 } """.strip(), self.encoder.encode( db_store.HumidityRecord( timestamp=datetime.datetime( - 2017, 3, 19, 15, 1, 23, 924000, tzinfo=pytz.utc), + 2017, 3, 19, 15, 1, tzinfo=pytz.utc), humidity=21.5))) self.assertJsonEqual( """ { - "timestamp": "20170319T150123Z", + "timestamp": "20170319T1501Z", "temperature": 21.5 } """.strip(), self.encoder.encode( db_store.TemperatureRecord( timestamp=datetime.datetime( - 2017, 3, 19, 15, 1, 23, 924000, tzinfo=pytz.utc), + 2017, 3, 19, 15, 1, tzinfo=pytz.utc), temperature=21.5))) self.assertJsonEqual( """ { - "timestamp": "20170319T150123Z", + "timestamp": "20170319T1501Z", "water_pumped": 302.5 } """.strip(), self.encoder.encode( db_store.WateringEventRecord( timestamp=datetime.datetime( - 2017, 3, 19, 15, 1, 23, 924000, tzinfo=pytz.utc), + 2017, 3, 19, 15, 1, tzinfo=pytz.utc), water_pumped=302.5)))