From 1cbe34b7cefbddd819013830a24a012028ea91f1 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Wed, 18 Oct 2023 09:29:33 -0700 Subject: [PATCH] Fix time serialization issues (#707) - Update Chrono to fix compilation issues. - Update leap second tests. Signed-off-by: David Calavera --- lambda-events/Cargo.toml | 7 +++++-- lambda-events/src/encodings/time.rs | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lambda-events/Cargo.toml b/lambda-events/Cargo.toml index e401bfff..73ab06d8 100644 --- a/lambda-events/Cargo.toml +++ b/lambda-events/Cargo.toml @@ -25,12 +25,15 @@ serde_with = { version = "^3", features = ["json"], optional = true } serde_json = "^1" serde_dynamo = { version = "^4.1", optional = true } bytes = { version = "1", features = ["serde"], optional = true } -chrono = { version = "0.4.23", default-features = false, features = [ +chrono = { version = "0.4.31", default-features = false, features = [ "clock", "serde", "std", ], optional = true } -query_map = { version = "^0.7", features = ["serde", "url-query"], optional = true } +query_map = { version = "^0.7", features = [ + "serde", + "url-query", +], optional = true } flate2 = { version = "1.0.24", optional = true } [features] diff --git a/lambda-events/src/encodings/time.rs b/lambda-events/src/encodings/time.rs index 390927ca..a550b7b0 100644 --- a/lambda-events/src/encodings/time.rs +++ b/lambda-events/src/encodings/time.rs @@ -279,12 +279,12 @@ mod test { let encoded = serde_json::to_string(&instance).unwrap(); assert_eq!(encoded, String::from(r#"{"v":"427683600.002"}"#)); - // Make sure milliseconds are included. + // Make sure leap seconds are included. let instance = Test { - v: Utc.ymd(1983, 7, 22).and_hms_nano(1, 0, 0, 1_234_000_000), + v: Utc.ymd(1983, 7, 22).and_hms_nano(23, 59, 59, 1_999_999_999), }; let encoded = serde_json::to_string(&instance).unwrap(); - assert_eq!(encoded, String::from(r#"{"v":"427683601.234"}"#)); + assert_eq!(encoded, String::from(r#"{"v":"427766400.999"}"#)); } #[test]