fix(hermes_time): implement reset_cache() referenced in docstrings (#41728)
The module docstring and get_timezone()/cache comments documented a reset_cache() helper for forcing tz re-resolution after config changes, but the function was never defined — doc-followers calling it hit AttributeError. Adds the helper to clear the cached tz state. Surfaced in #32043.
This commit is contained in:
parent
5408013369
commit
ad8e57793d
@ -88,6 +88,19 @@ def get_timezone() -> Optional[ZoneInfo]:
|
|||||||
return _cached_tz
|
return _cached_tz
|
||||||
|
|
||||||
|
|
||||||
|
def reset_cache() -> None:
|
||||||
|
"""Clear the cached timezone so the next call re-resolves it.
|
||||||
|
|
||||||
|
Call this after the configured timezone may have changed (e.g. after a
|
||||||
|
config edit or ``HERMES_TIMEZONE`` update) to force ``get_timezone()`` /
|
||||||
|
``now()`` to read the new value instead of the value cached at first use.
|
||||||
|
"""
|
||||||
|
global _cached_tz, _cached_tz_name, _cache_resolved
|
||||||
|
_cached_tz = None
|
||||||
|
_cached_tz_name = None
|
||||||
|
_cache_resolved = False
|
||||||
|
|
||||||
|
|
||||||
def now() -> datetime:
|
def now() -> datetime:
|
||||||
"""
|
"""
|
||||||
Return the current time as a timezone-aware datetime.
|
Return the current time as a timezone-aware datetime.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user