Skip to content

Commit cd33a93

Browse files
committed
modify the way the local TZ is detected
Signed-off-by: Grant Ramsay <[email protected]>
1 parent 25aa110 commit cd33a93

File tree

4 files changed

+556
-490
lines changed

4 files changed

+556
-490
lines changed

TODO.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ These below are from Issues or PRs in the original repository.
2222
the test logic not production code.
2323
- catch invalid cache type exceptions and raise a more informative error
2424
message.
25+
- configure the log time display format in the `Cache` class. Make it
26+
totally configurable through an optional parameter and/or detect and use the
27+
preferred local time format.

fastapi_redis_cache/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
Optional,
1313
Union,
1414
)
15-
from zoneinfo import ZoneInfo
15+
16+
import tzlocal
1617

1718
from fastapi_redis_cache.enums import RedisEvent, RedisStatus
1819
from fastapi_redis_cache.key_gen import get_cache_key
@@ -261,5 +262,5 @@ def get_etag(cached_data: Union[str, bytes, dict[str, Any]]) -> str:
261262
@staticmethod
262263
def get_log_time() -> str:
263264
"""Get a timestamp to include with a log message."""
264-
local_tz = ZoneInfo("localtime")
265+
local_tz = tzlocal.get_localzone()
265266
return datetime.now(local_tz).strftime(LOG_TIMESTAMP)

0 commit comments

Comments
 (0)