mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
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
1 changed files with 13 additions and 0 deletions
|
|
@ -88,6 +88,19 @@ def get_timezone() -> Optional[ZoneInfo]:
|
|||
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:
|
||||
"""
|
||||
Return the current time as a timezone-aware datetime.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue