fix tz issue
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 5m36s

This commit is contained in:
Nicholas Orlowsky 2025-10-07 19:51:31 -04:00
parent 12e4f08a6a
commit bc730807e1
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B

View file

@ -1,3 +1,4 @@
use chrono_tz::America::New_York;
use libseptastic::{direction::Direction, stop_schedule::{Trip, TripTracking}}; use libseptastic::{direction::Direction, stop_schedule::{Trip, TripTracking}};
use std::{cmp::Ordering, collections::BTreeMap}; use std::{cmp::Ordering, collections::BTreeMap};
use serde::{Serialize}; use serde::{Serialize};
@ -62,7 +63,8 @@ pub fn build_timetables(
let mut results = Vec::new(); let mut results = Vec::new();
for direction in directions { for direction in directions {
let now = chrono::Local::now(); let now_utc = chrono::Utc::now();
let now = now_utc.with_timezone(&New_York);
let naive_time = now.time(); let naive_time = now.time();
let seconds_since_midnight = naive_time.num_seconds_from_midnight(); let seconds_since_midnight = naive_time.num_seconds_from_midnight();
@ -167,10 +169,12 @@ mod filters {
let total_minutes = seconds_since_midnight / 60; let total_minutes = seconds_since_midnight / 60;
let (hours, ampm) = { let (hours, ampm) = {
let hrs = total_minutes / 60; let hrs = total_minutes / 60;
if hrs > 12 { if hrs >= 12 {
(hrs - 12, "PM") (hrs - 12, "PM")
} else { } else if hrs > 0 {
(hrs, "AM") (hrs, "AM")
} else {
(12, "AM")
} }
}; };
let minutes = total_minutes % 60; let minutes = total_minutes % 60;