Show match finish times in the browser timezone
CI / Build and push docker image (push) Successful in 2m18s
CI / Build and push docker image (push) Successful in 2m18s
The history table truncated finished_at, which the API serializes in UTC, so the Finished column always showed UTC wall time. Parse the timestamp with the browser's Date and render its local components, keeping the existing YYYY-MM-DD HH:MM layout.
This commit is contained in:
@@ -291,6 +291,13 @@ pub fn fmt_points(points: f64) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Render a calendar instant as `YYYY-MM-DD HH:MM`. `month` is 0-based
|
||||
/// (the JavaScript `Date` convention); the other components are as
|
||||
/// returned by `Date`'s local-time getters.
|
||||
pub fn fmt_datetime_parts(year: u32, month: u32, day: u32, hour: u32, minute: u32) -> String {
|
||||
format!("{year:04}-{:02}-{day:02} {hour:02}:{minute:02}", month + 1)
|
||||
}
|
||||
|
||||
/// The caller's Elo rating for one game type (GET /api/me/ratings).
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
@@ -658,6 +665,12 @@ mod tests {
|
||||
assert_eq!("2.5", fmt_points(2.5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fmt_datetime_parts_pads_and_offsets_month() {
|
||||
assert_eq!("2026-09-19 05:02", fmt_datetime_parts(2026, 8, 19, 5, 2));
|
||||
assert_eq!("2026-01-01 00:00", fmt_datetime_parts(2026, 0, 1, 0, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leaderboard_points_accept_floats() {
|
||||
let e: LeaderboardEntry = serde_json::from_value(json!({
|
||||
|
||||
Reference in New Issue
Block a user