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: handle month overflow in duration_in_seconds for multi-month durations (#23099)
JiangNan0d3735f9c0ee
diff --git a/litellm/litellm_core_utils/duration_parser.py b/litellm/litellm_core_utils/duration_parser.pyindex 70c28c4e067..6d2b4226ff4 100644--- a/litellm/litellm_core_utils/duration_parser.py+++ b/litellm/litellm_core_utils/duration_parser.py@@ -64,12 +64,10 @@ def duration_in_seconds(duration: str) -> int:now = time.time()current_time = datetime.fromtimestamp(now)- if current_time.month == 12:- target_year = current_time.year + 1- target_month = 1- else:- target_year = current_time.year- target_month = current_time.month + value+ # Calculate target month and year, handling overflow past December+ total_months = current_time.month - 1 + value # 0-indexed months+ target_year = current_time.year + total_months // 12+ target_month = total_months % 12 + 1 # back to 1-indexed# Determine the day to set for next monthtarget_day = current_time.day