Use int timestamps for rate limit reset_at (#5383)
The backend will be returning unix timestamps (seconds since epoch) instead of RFC 3339 strings. This will make it more ergonomic for developers to integrate against - no string parsing.
This commit is contained in:
@@ -3,6 +3,7 @@ use crate::chatwidget::get_limits_duration;
|
||||
use super::helpers::format_reset_timestamp;
|
||||
use chrono::DateTime;
|
||||
use chrono::Local;
|
||||
use chrono::Utc;
|
||||
use codex_core::protocol::RateLimitSnapshot;
|
||||
use codex_core::protocol::RateLimitWindow;
|
||||
|
||||
@@ -34,8 +35,7 @@ impl RateLimitWindowDisplay {
|
||||
fn from_window(window: &RateLimitWindow, captured_at: DateTime<Local>) -> Self {
|
||||
let resets_at = window
|
||||
.resets_at
|
||||
.as_deref()
|
||||
.and_then(|value| DateTime::parse_from_rfc3339(value).ok())
|
||||
.and_then(|seconds| DateTime::<Utc>::from_timestamp(seconds, 0))
|
||||
.map(|dt| dt.with_timezone(&Local))
|
||||
.map(|dt| format_reset_timestamp(dt, captured_at));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user