Add default ma_attempts param to get_local_time

This commit is contained in:
Keith Schincke 2024-06-04 12:03:00 -05:00
parent 1b0c94a386
commit 932e56cca7

View file

@ -203,11 +203,13 @@ class NetworkBase:
"""
return url.replace(" ", "+").replace("%", "%25").replace(":", "%3A")
def get_strftime(self, time_format, location=None):
def get_strftime(self, time_format, location=None, max_attempts=10):
"""
Fetch a custom strftime relative to your location.
:param str location: Your city and country, e.g. ``"America/New_York"``.
:param max_attempts: The maximum number of of attempts to connect to WiFi before
failing or use None to disable. Defaults to 10.
"""
# pylint: disable=line-too-long
@ -259,12 +261,14 @@ class NetworkBase:
return reply
def get_local_time(self, location=None):
def get_local_time(self, location=None, max_attempts=10):
# pylint: disable=line-too-long
"""
Fetch and "set" the local time of this microcontroller to the local time at the location, using an internet time API.
:param str location: Your city and country, e.g. ``"America/New_York"``.
:param max_attempts: The maximum number of of attempts to connect to WiFi before
failing or use None to disable. Defaults to 10.
"""
reply = self.get_strftime(TIME_SERVICE_FORMAT, location=location)