diff --git a/tortoise/timezone.py b/tortoise/timezone.py index 8cccefbeb..450dd04c4 100644 --- a/tortoise/timezone.py +++ b/tortoise/timezone.py @@ -1,3 +1,4 @@ +from functools import cache import os from datetime import datetime, time, tzinfo from typing import Optional, Union @@ -5,6 +6,7 @@ import pytz +@cache def get_use_tz() -> bool: """ Get use_tz from env set in Tortoise config. @@ -12,6 +14,7 @@ def get_use_tz() -> bool: return os.environ.get("USE_TZ") == "True" +@cache def get_timezone() -> str: """ Get timezone from env set in Tortoise config. @@ -29,6 +32,7 @@ def now() -> datetime: return datetime.now(get_default_timezone()) +@cache def get_default_timezone() -> tzinfo: """ Return the default time zone as a tzinfo instance.