From aa674527aa05734256666c8bafc588b52ea9324e Mon Sep 17 00:00:00 2001 From: Laksh0p Date: Thu, 5 Feb 2026 16:18:14 +0530 Subject: [PATCH 1/3] Return converted times from convert_time instead of printing Refactor WorldClock to collect results in a list and print them after conversion. --- pybites_tools/worldclock.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pybites_tools/worldclock.py b/pybites_tools/worldclock.py index bc7c069..37bad59 100644 --- a/pybites_tools/worldclock.py +++ b/pybites_tools/worldclock.py @@ -13,7 +13,6 @@ MINUTES_IN_HOUR = range(0, 60) MONTHS_IN_YEAR = range(1, 13) MAX_DAYS_IN_MONTH = range(1, 32) - load_dotenv() @@ -30,13 +29,13 @@ def convert_time( tzone: str = None, date_offset: bool = False, ) -> None: + results = [] try: timezones = json.loads(os.environ["TIMEZONE_LIST"]) except json.decoder.JSONDecodeError: raise WorldClockException( "JSON error occurred. Please check your .env file for syntax" ) - for zone in timezones: if tz.gettz(zone) is None: raise WorldClockException( @@ -62,8 +61,8 @@ def convert_time( if date_offset: formatted_time += f" {converted_time.strftime('%d %b %Y')}" - - print(f"{zone:25} {formatted_time}") + results.append((zone, formatted_time)) + return results def main(): @@ -83,7 +82,7 @@ def main(): args = parser.parse_args() try: - convert_time( + result = convert_time( args.hour, args.minute, args.year, @@ -95,7 +94,8 @@ def main(): except WorldClockException as exc: print(exc) sys.exit(1) - + for zone, time in result: + print(f"{zone:25} {time}") if __name__ == "__main__": main() From 4dd441e101731a93f52f7ba848ae9f8c0b97ad85 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 10:51:18 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pybites_tools/worldclock.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pybites_tools/worldclock.py b/pybites_tools/worldclock.py index 37bad59..7cf17aa 100644 --- a/pybites_tools/worldclock.py +++ b/pybites_tools/worldclock.py @@ -97,5 +97,6 @@ def main(): for zone, time in result: print(f"{zone:25} {time}") + if __name__ == "__main__": main() From f567b83a802ed76d28ca7b6f951d23d8f81feb35 Mon Sep 17 00:00:00 2001 From: Laksh0p Date: Thu, 5 Feb 2026 16:30:57 +0530 Subject: [PATCH 3/3] Update return type of function in worldclock.py Change return type from None to list of tuples. --- pybites_tools/worldclock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybites_tools/worldclock.py b/pybites_tools/worldclock.py index 7cf17aa..3e99304 100644 --- a/pybites_tools/worldclock.py +++ b/pybites_tools/worldclock.py @@ -28,7 +28,7 @@ def convert_time( day: int = None, tzone: str = None, date_offset: bool = False, -) -> None: +) -> list[tuple[str, str]]: results = [] try: timezones = json.loads(os.environ["TIMEZONE_LIST"])