fix: use PDT isntead of UTC

This commit is contained in:
Jet 2026-03-24 14:20:16 -07:00
parent 3dcd3f00d8
commit adb929227b
No known key found for this signature in database
3 changed files with 52 additions and 1 deletions

View file

@ -10,6 +10,7 @@ workspace = true
anyhow = "1.0"
axum = "0.8"
chrono = "0.4"
chrono-tz = "0.10"
noisebell-common = { path = "../noisebell-common" }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.33", features = ["bundled"] }

View file

@ -5,6 +5,7 @@ use axum::http::{header, HeaderMap, StatusCode};
use axum::response::{IntoResponse, Response};
use axum::Json;
use chrono::{DateTime, Utc};
use chrono_tz::America::Los_Angeles;
use noisebell_common::{validate_bearer, CacheStatusResponse, DoorStatus, WebhookPayload};
use tokio::sync::Mutex;
use tracing::{error, info};
@ -115,7 +116,9 @@ fn unix_now() -> u64 {
fn format_full_timestamp(ts: u64) -> String {
DateTime::from_timestamp(ts as i64, 0)
.map(|dt: DateTime<Utc>| dt.format("%A, %B %-d, %Y at %-I:%M:%S %p UTC").to_string())
.map(|dt: DateTime<Utc>| {
dt.with_timezone(&Los_Angeles).format("%A, %B %-d, %Y at %-I:%M:%S %p %Z").to_string()
})
.unwrap_or_else(|| format!("unix timestamp {ts}"))
}
@ -364,6 +367,18 @@ mod tests {
assert_eq!(format_duration(3_723), "1 hour and 2 minutes");
}
#[test]
fn format_full_timestamp_uses_san_francisco_timezone() {
let ts = 1_711_312_063;
let expected = DateTime::from_timestamp(ts, 0)
.unwrap()
.with_timezone(&Los_Angeles)
.format("%A, %B %-d, %Y at %-I:%M:%S %p %Z")
.to_string();
assert_eq!(format_full_timestamp(ts as u64), expected);
}
#[test]
fn status_summary_includes_since_and_last_checked() {
let summary = status_summary(DoorStatus::Open, Some(1_000), Some(1_125), 1_180);