Skip to content

Commit 201554f

Browse files
committed
Cache timezone related settings
1 parent da1f448 commit 201554f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tortoise/timezone.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
from functools import cache
12
import os
23
from datetime import datetime, time, tzinfo
34
from typing import Optional, Union
45

56
import pytz
67

78

9+
@cache
810
def get_use_tz() -> bool:
911
"""
1012
Get use_tz from env set in Tortoise config.
1113
"""
1214
return os.environ.get("USE_TZ") == "True"
1315

1416

17+
@cache
1518
def get_timezone() -> str:
1619
"""
1720
Get timezone from env set in Tortoise config.
@@ -29,6 +32,7 @@ def now() -> datetime:
2932
return datetime.now(get_default_timezone())
3033

3134

35+
@cache
3236
def get_default_timezone() -> tzinfo:
3337
"""
3438
Return the default time zone as a tzinfo instance.

0 commit comments

Comments
 (0)