The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(duration_parser.py): handle 0 value
Krrish Dholakia576947b4fe82
diff --git a/litellm/litellm_core_utils/duration_parser.py b/litellm/litellm_core_utils/duration_parser.pyindex 08f1d4c82d0..08e5323c30c 100644--- a/litellm/litellm_core_utils/duration_parser.py+++ b/litellm/litellm_core_utils/duration_parser.py@@ -1,7 +1,7 @@"""Helper utilities for parsing durations - 1s, 1d, 10d, 30d, 1mo, 2mo-duration_in_seconds is used in diff parts of the code base, example+duration_in_seconds is used in diff parts of the code base, example- Router - Provider budget routing- Proxy - Key, Team Generation"""@@ -192,6 +192,10 @@ def _handle_day_reset(current_time: datetime, base_midnight: datetime, value: int, timezone: timezone) -> datetime:"""Handle day-based reset times."""+ # Handle zero value - immediate expiration+ if value == 0:+ return current_time+if value == 1: # Daily reset at midnightreturn base_midnight + timedelta(days=1)elif value == 7: # Weekly reset on Monday at midnight@@ -234,6 +238,10 @@ def _handle_hour_reset(current_time: datetime, base_midnight: datetime, value: int) -> datetime:"""Handle hour-based reset times."""+ # Handle zero value - immediate expiration+ if value == 0:+ return current_time+current_hour = current_time.hourcurrent_minute = current_time.minutecurrent_second = current_time.second@@ -266,6 +274,10 @@ def _handle_minute_reset(current_time: datetime, base_midnight: datetime, value: int) -> datetime:"""Handle minute-based reset times."""+ # Handle zero value - immediate expiration+ if value == 0:+ return current_time+current_hour = current_time.hourcurrent_minute = current_time.minutecurrent_second = current_time.second@@ -306,6 +318,10 @@ def _handle_second_reset(current_time: datetime, base_midnight: datetime, value: int) -> datetime:"""Handle second-based reset times."""+ # Handle zero value - immediate expiration+ if value == 0:+ return current_time+current_hour = current_time.hourcurrent_minute = current_time.minutecurrent_second = current_time.second