Ë
    tPêj  ã                   óž   — d dl m Z mZmZ d dlmZmZ d dlZd dlmZ  G d„ de«      Z	de
defd	„Zdefd
„Zde	fd„Zdede	de fd„Zdede fd„Zy)é    )ÚdatetimeÚtimeÚtimezone)Ú	BaseModelÚ
ConfigDictN)Ú get_next_standardized_reset_timec                   óN   — e Zd ZU dZ ed¬«      ZdZeed<    e	dd«      Z
e	ed<   y)	ÚBudgetResetSettingsa  Immutable, validated settings that govern when budgets reset.

    Parsed once from `litellm_settings` and injected into consumers (the reset
    job, management endpoints) so reset times never depend on reaching into
    module-level globals at call time.
    T)ÚfrozenÚUTCr   r   Úreset_time_of_dayN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úmodel_configr   ÚstrÚ__annotations__r   r   © ó    ún/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/proxy/common_utils/timezone_utils.pyr
   r
   	   s.   … ññ  TÔ*€Là€HˆcÓÙ" 1 a›jÐ�tÔ(r   r
   ÚrawÚreturnc                 ó8  — | �| dk(  rt        dd«      S t        | t        «      st        d| ›d�«      ‚dD ]F  }	 t	        j
                  | |«      }t        |j                  |j                  |j                  ¬«      c S  t        d| ›d�«      ‚# t        $ r Y Œcw xY w)zôParse a `budget_reset_time` config value (e.g. "12:00") into a `time`.

    Falls back to midnight when unset; raises a clear error on a malformed value
    so a bad config fails loudly at startup instead of silently resetting at midnight.
    Ú r   zInvalid budget_reset_time z7; must be a quoted 24-hour 'HH:MM' string, e.g. "12:00")z%H:%Mz%H:%M:%S)ÚhourÚminuteÚsecondz?; expected a 24-hour 'HH:MM' or 'HH:MM:SS' string, e.g. "12:00")	r   Ú
isinstancer   Ú
ValueErrorr   Ústrptimer   r   r   )r   ÚfmtÚparseds      r   Úparse_budget_reset_timer$      s¬   € ð €{�c˜R’iÜ�A�q‹zÐÜ�cœ3ÔÜÐ5°c°WÐ<uÐvÓwÐwØ$ò ˆð	Ü×&Ñ& s¨CÓ0ˆFÜ˜VŸ[™[°·±ÀvÇ}Á}ÔUÒUðô Ø
$ S GÐ+lÐmóð øô ò 	Ùð	ús   ¹ABÂ	BÂBc                  ó,   — t        t        dd«      xs dS )zõ
    Get the budget reset timezone from litellm_settings.
    Falls back to UTC if not specified.

    litellm_settings values are set as attributes on the litellm module
    by proxy_server.py at startup (via setattr(litellm, key, value)).
    r   Nr   )ÚgetattrÚlitellmr   r   r   Úget_budget_reset_timezoner(   ,   s   € ô ”7˜J¨Ó-Ò6°Ð6r   c            
      ó\   — t        t        «       t        t        t        dd«      «      ¬«      S )z�Build validated reset settings from litellm_settings. Raises on a malformed
    `budget_reset_time`, which lets the proxy fail fast at startup.Úbudget_reset_timeN)r   r   )r
   r(   r$   r&   r'   r   r   r   Úget_budget_reset_settingsr+   7   s*   € ô Ü*Ó,Ü1´'¼'ÐCVÐX\Ó2]Ó^ôð r   Úbudget_durationÚsettingsc                 óŠ   — t        | t        j                  t        j                  «      |j                  |j
                  ¬«      S )zJCompute the next reset time for a budget duration using injected settings.)ÚdurationÚcurrent_timeÚtimezone_strr   )r   r   Únowr   Úutcr   )r,   r-   s     r   Úcompute_budget_reset_atr4   @   s4   € ä+Ø Ü—\‘\¤(§,¡,Ó/Ø×&Ñ&Ø"×4Ñ4ô	ð r   c                 ó*   — t        | t        «       «      S )zÿGet the budget reset time using the globally-configured timezone and reset time.

    Thin wrapper over `compute_budget_reset_at` for callers that don't yet receive
    `BudgetResetSettings` by injection (creation/update endpoints, startup backfill).
    )r4   r+   )r,   s    r   Úget_budget_reset_timer6   J   s   € ô # ?Ô4MÓ4OÓPÐPr   )r   r   r   Úpydanticr   r   r'   Ú*litellm.litellm_core_utils.duration_parserr   r
   Úobjectr$   r   r(   r+   r4   r6   r   r   r   ú<module>r:      s~   ðß -Ñ -ç *ã Ý Wô)˜)ô )ð ð ¨Dó ð*7 3ó 7ðÐ#6ó ð¨Sð Ð<Oð ÐT\ó ðQ¨3ð Q°8ô Qr   