Skip to content

Commit

Permalink
fixed Azure#481 by replacing chrono 0.4 with time 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JanZachmann committed Nov 8, 2022
1 parent bc310c7 commit 2a0b07f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cert/cert-renewal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "cert-renewal"
version = "0.1.0"
version = "0.1.1"
authors = ["Azure IoT Edge Devs"]
edition = "2021"

[dependencies]
async-trait = "0.1"
chrono = "0.4"
datetime = { package = "time", version = "0.3", features = ["formatting"] }
futures-util = "0.3"
log = "0.4"
openssl = "0.10"
Expand Down
13 changes: 6 additions & 7 deletions cert/cert-renewal/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ impl std::fmt::Display for Time {
if self == &Time::forever() {
write!(f, "the end of time")
} else {
let date_time = chrono::NaiveDateTime::from_timestamp(self.0, 0);
let date_time = chrono::DateTime::<chrono::Utc>::from_utc(date_time, chrono::Utc);

write!(f, "{}", date_time.to_rfc3339())
let date_time = datetime::OffsetDateTime::from_unix_timestamp(self.0).map_err(|_| std::fmt::Error)?;
let date_time = date_time.format(&datetime::format_description::well_known::Rfc3339).map_err(|_| std::fmt::Error)?;
write!(f, "{}", date_time)
}
}
}
Expand Down Expand Up @@ -160,13 +159,13 @@ mod tests {

#[test]
fn time_display() {
assert_eq!("1970-01-01T00:00:00+00:00", Time::from(0).to_string());
assert_eq!("1970-01-01T00:00:00Z", Time::from(0).to_string());
assert_eq!(
"1938-04-24T22:13:20+00:00",
"1938-04-24T22:13:20Z",
Time::from(-1_000_000_000).to_string()
);
assert_eq!(
"2001-09-09T01:46:40+00:00",
"2001-09-09T01:46:40Z",
Time::from(1_000_000_000).to_string()
);
assert_eq!("the end of time", Time::forever().to_string());
Expand Down

0 comments on commit 2a0b07f

Please sign in to comment.