Fix date format for Garmin body composition API call

Changed the date format passed to api.get_body_composition from a datetime object to a string in 'YYYY-MM-DD' format to match API requirements. Also updated .gitignore to exclude .garminconnect files.
This commit is contained in:
João Vitória Silva
2025-11-14 22:25:54 +00:00
parent dc3b3017d2
commit 8580f3020a
2 changed files with 3 additions and 1 deletions

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@ docker-compose.yml
.env
# aux folder
.garminconnect
aux_scripts/.garminconnect
# Python

View File

@@ -82,12 +82,13 @@ def init_api(email, password):
date = get_date()
date_object = datetime.datetime.strptime(date, "%d-%m-%Y")
date_string = date_object.strftime("%Y-%m-%d")
if not api:
api = init_api(email, password)
if api:
garmin_bc = api.get_body_composition(date_object, date_object)
garmin_bc = api.get_body_composition(date_string, date_string)
if garmin_bc is None:
# Log an informational event if no body composition were found