From e84682c391cac7b7886bd437fbcb313009a5d3ad Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Mon, 10 Sep 2018 11:02:38 +0200 Subject: [PATCH] Fix error when GPS send None timestamp --- circuitpython/code/cameteo.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/circuitpython/code/cameteo.py b/circuitpython/code/cameteo.py index 3921e30..f91df6f 100644 --- a/circuitpython/code/cameteo.py +++ b/circuitpython/code/cameteo.py @@ -362,13 +362,10 @@ class GPSData(Data): if self._enable: self._gps_current_fix = int(time.monotonic()) - self.data['time'] = TIME_FORMAT.format( - self._gps.timestamp_utc.tm_year, - self._gps.timestamp_utc.tm_mon, - self._gps.timestamp_utc.tm_mday, - self._gps.timestamp_utc.tm_hour, - self._gps.timestamp_utc.tm_min, - self._gps.timestamp_utc.tm_sec) + if self._gps.timestamp_utc is not None: + self.data['time'] = TIME_FORMAT.format(*self._gps.timestamp_utc[0:6]) + else: + self.data['time'] = TIME_FORMAT.format(2018, 9, 10, 10, 0, 0) if self._gps.has_fix: self._gps_last_fix = self._gps_current_fix self.data['lat'] = self._gps.latitude