Skip to content

Commit

Permalink
Fix time serialization issues (#707)
Browse files Browse the repository at this point in the history
- Update Chrono to fix compilation issues.
- Update leap second tests.

Signed-off-by: David Calavera <david.calavera@gmail.com>
  • Loading branch information
calavera authored Oct 18, 2023
1 parent d1687e1 commit 1cbe34b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lambda-events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions lambda-events/src/encodings/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 1cbe34b

Please sign in to comment.