Add default ma_attempts param to get_local_time
This commit is contained in:
parent
1b0c94a386
commit
932e56cca7
1 changed files with 6 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue