Skip to content

Commit

Permalink
timestamp bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Oct 10, 2024
1 parent bff3486 commit 70cbe10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "zotgtfs"
license = "AGPL-3.0"
version = "0.3.6"
version = "0.3.7"
edition = "2021"
description = "Conversion of Anteater Express data to GTFS Schedule and Realtime"

Expand Down
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use chrono_tz::Tz;
// Author(s): Jacob Whitecotton, Kyler Chin
// Version: 4/6/2024

use std::time::{SystemTime, UNIX_EPOCH};

/**
* Fetches jsonp data from ucirvine's transit feed and converts it into gtfs_rt
*/
Expand Down Expand Up @@ -76,7 +78,7 @@ fn gtfs_rt_from_string(
header: FeedHeader {
gtfs_realtime_version: String::from("2.0"),
incrementality: None,
timestamp: None,
timestamp: SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs(),
},
entity: empty_entity,
};
Expand Down Expand Up @@ -107,8 +109,8 @@ fn gtfs_rt_from_string(
let anteater_gtfs = gtfs_realtime::FeedMessage {
header: FeedHeader {
gtfs_realtime_version: String::from("2.0"),
incrementality: Some(1),
timestamp: Some(SystemTime::now().elapsed()?.as_secs()),
incrementality: None,
timestamp: Some(SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs()),
},
entity: anteater_entities,
};
Expand Down Expand Up @@ -412,7 +414,9 @@ mod tests {

#[tokio::test]
async fn get_gtfs_rt_is_ok() {
assert!(get_gtfs_rt().await.is_ok());
let get_data = get_gtfs_rt().await;
assert!(get_data.is_ok());
println!("Got data successfully: {:?}", get_data);
}

// This only passes when Anteater Express is in service (lol)
Expand Down

0 comments on commit 70cbe10

Please sign in to comment.