From 6087d610c503786d29065203794a0778dacdaa67 Mon Sep 17 00:00:00 2001 From: oskvr37 Date: Fri, 26 Jul 2024 00:19:54 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20format=20time=20to=20days=20and=20h?= =?UTF-8?q?ours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tiddl/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tiddl/__init__.py b/tiddl/__init__.py index 63f5fa5..2738816 100644 --- a/tiddl/__init__.py +++ b/tiddl/__init__.py @@ -42,9 +42,11 @@ def main(): ) print("✅ Refreshed token!") - # TODO: format time to days and hours ✨ time_to_expire = config["token_expires_at"] - t_now - print(f"✅ Token good for {time_to_expire}s") + days, hours = time_to_expire // (24 * 3600), time_to_expire % (24 * 3600) // 3600 + days_text = f" {days} {"day" if days == 1 else "days"}" if days else "" + hours_text = f" {hours} {"hour" if hours == 1 else "hours"}" if hours else "" + print(f"✅ Token good for{days_text}{hours_text}") api = TidalApi( config["token"], config["user"]["user_id"], config["user"]["country_code"]