Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion v3/as_drivers/as_GPS/as_GPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _set_date_time(self, utc_string, date_string):
m = int(date_string[2:4]) # month
y = int(date_string[4:6]) + 2000 # year
wday = self._week_day(y, m, d)
t = int(self._mktime((y, m, d, hrs, mins, int(secs), wday - 1, 0, 0)))
t = int(self._mktime((y, m, d, hrs, mins, int(secs), wday - 1, 0, 0)))
self.epoch_time = t # This is the fundamental datetime reference.
self._dtset(wday) # Subclass may override

Expand Down Expand Up @@ -624,3 +624,16 @@ def date_string(self, formatting=MDY):
from .as_GPS_utils import date_string

return date_string(self, formatting)

# ===== MicroPython-friendly ISO 8601 format =====
@property
def iso_datetime(self):
"""Returns an ISO 8601-like datetime string."""
if self.epoch_time is None:
return "1970-01-01T00:00:00" # Default/fallback

tm = self._localtime(self.epoch_time)
return '{}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}'.format(
tm[0], tm[1], tm[2], tm[3], tm[4], tm[5]
)