30 lines
1.3 KiB
Markdown
30 lines
1.3 KiB
Markdown
|
|
# API Timezone Handling
|
||
|
|
|
||
|
|
API quota reset timestamps are provider-specific and often lack timezone metadata. Always convert to UTC before scheduling retries.
|
||
|
|
|
||
|
|
## Provider timezone map
|
||
|
|
|
||
|
|
| Provider | Timezone | UTC offset | Example |
|
||
|
|
|----------|----------|-----------|---------|
|
||
|
|
| Z.AI / GLM (Zhipu) | Asia/Shanghai | UTC+8 | "15:43" → 07:43 UTC |
|
||
|
|
| DeepSeek | Asia/Shanghai | UTC+8 | Chinese company, Hangzhou |
|
||
|
|
| OpenRouter | UTC | UTC+0 | Timestamps are UTC |
|
||
|
|
| Anthropic | America/Los_Angeles | UTC-8/-7 (PDT/PST) | California |
|
||
|
|
| OpenAI | America/Los_Angeles | UTC-8/-7 (PDT/PST) | California |
|
||
|
|
|
||
|
|
## Detection
|
||
|
|
|
||
|
|
Use `scripts/quota_reset_eta.py` to parse error messages and compute the correct
|
||
|
|
reset time. It detects providers via keywords ("z.ai", "智谱", "使用上限", "deepseek",
|
||
|
|
"openrouter", "anthropic", "openai") and applies the correct timezone.
|
||
|
|
|
||
|
|
## Common traps
|
||
|
|
|
||
|
|
- **Chinese error messages lack timezone**: "您的限额将在 2026-06-18 15:43:27 重置"
|
||
|
|
means Beijing time (UTC+8), not UTC.
|
||
|
|
- **English messages may include timezone**: "reset on 2026-06-20T00:00:00Z"
|
||
|
|
is explicit (Z = UTC). Trust explicit timezone over provider guess.
|
||
|
|
- **Retry-After header**: in seconds from now, not an absolute timestamp.
|
||
|
|
- **CEST vs CET**: Slovenia uses CEST (UTC+2) in summer, CET (UTC+1) in winter.
|
||
|
|
Always compute from datetime objects, not hardcoded offsets.
|