Skip to content

Commit c75df9f

Browse files
author
Melissa LeBlanc-Williams
committed
Added error checking to unixtime
1 parent ac7b684 commit c75df9f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

adafruit_featherwing/rtc_featherwing.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,15 @@ def unixtime(self):
289289
"""
290290
The Current Date and Time in Unix Time
291291
"""
292-
return time.mktime(self._rtc.datetime)
292+
try:
293+
return time.mktime(self._rtc.datetime)
294+
except (ValueError, RuntimeError) as error:
295+
print("There was an error attempting to run time.mktime() on this board")
293296

294297
@unixtime.setter
295298
def unixtime(self, unixtime):
296299
if isinstance(unixtime, int):
297-
self._rtc.datetime = time.localtime(unixtime)
300+
try:
301+
self._rtc.datetime = time.localtime(unixtime)
302+
except (ValueError, RuntimeError) as error:
303+
print("There was an error attempting to run time.localtime() on this board")

0 commit comments

Comments
 (0)