diff --git a/Cargo.lock b/Cargo.lock index 75f63277b..92169d96a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,6 +141,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" +dependencies = [ + "num-traits", +] + [[package]] name = "clang-sys" version = "1.7.0" @@ -246,12 +255,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "iter-read" version = "0.3.1" @@ -643,8 +646,8 @@ dependencies = [ "bincode", "bindgen", "cc", + "chrono", "clap", - "humantime", "libc", "pkg-config", "rand", diff --git a/Cargo.toml b/Cargo.toml index a8943c646..5f62df0a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,11 +23,11 @@ codegen-units=1 thiserror = "1.0" libc = "0.2.155" streaming-iterator = "0.1.5" -humantime = {version = "2.1.0", optional = true} serde = {version = "1.0.203", features = ["derive"], optional = true} serde_json = {version = "1.0.120", optional = true} bincode = {version = "1.3.1", optional = true} tskit-derive = {version = "0.2.0", path = "tskit-derive", optional = true} +chrono = { version = "0.4.40", default-features = false, features = ["now", "std"] , optional = true} [dev-dependencies] anyhow = {version = "1.0.86"} @@ -38,9 +38,6 @@ serde_json = {version = "1.0.120"} bincode = "1.3.1" rand = "0.8.3" rand_distr = "0.4.0" -humantime = {version = "2.1.0"} -# chrono is out (for now) due to security issues -# chrono = "0.4.19" [build-dependencies] bindgen = "0.69.4" @@ -49,7 +46,7 @@ pkg-config = "0.3" [features] bindings = [] -provenance = ["humantime"] +provenance = ["chrono"] derive = ["tskit-derive", "serde", "serde_json", "bincode"] [package.metadata.docs.rs] diff --git a/src/sys/provenance_table.rs b/src/sys/provenance_table.rs index 2562b9ad9..c52591e17 100644 --- a/src/sys/provenance_table.rs +++ b/src/sys/provenance_table.rs @@ -45,7 +45,7 @@ impl ProvenanceTable { "empty provenance record".to_owned(), )); } - let timestamp = humantime::format_rfc3339(std::time::SystemTime::now()).to_string(); + let timestamp = chrono::Utc::now().to_string(); let rv = unsafe { tsk_provenance_table_add_row( self.as_mut(), diff --git a/src/table_collection.rs b/src/table_collection.rs index 866451340..f24542adb 100644 --- a/src/table_collection.rs +++ b/src/table_collection.rs @@ -1047,7 +1047,7 @@ impl TableCollection { /// specification. /// This formatting approach has been the most straightforward method /// for supporting round trips to/from a [`crate::provenance::ProvenanceTable`]. - /// The implementations used here use the [`humantime`](https://docs.rs/humantime/latest/humantime/) crate. + /// The implementations used here use the [`chrono`](https://docs.rs/chrono/latest/chrono/) crate. /// /// # Parameters /// @@ -1076,9 +1076,9 @@ impl TableCollection { /// let timestamp = prov_ref.timestamp(0).unwrap(); /// assert_eq!(timestamp, row_0.timestamp); /// - /// // You can get the `humantime::Timestamp` object back from the `String`: + /// // You can get the `chrono` object back from the `String`: /// use core::str::FromStr; - /// let timestamp_string = humantime::Timestamp::from_str(×tamp).unwrap(); + /// let timestamp_string = chrono::DateTime::::from_str(×tamp).unwrap(); /// /// // Provenance transfers to the tree sequences /// let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap(); diff --git a/src/trees/treeseq.rs b/src/trees/treeseq.rs index a935fe1bb..a4cc21933 100644 --- a/src/trees/treeseq.rs +++ b/src/trees/treeseq.rs @@ -431,7 +431,7 @@ impl TreeSequence { /// specification. /// This formatting approach has been the most straightforward method /// for supporting round trips to/from a [`crate::provenance::ProvenanceTable`]. - /// The implementations used here use the [`humantime`](https://docs.rs/humantime/latest/humantime/) crate. + /// The implementations used here use the [`chrono`](https://docs.rs/chrono/latest/chrono/) crate. /// /// # Parameters /// @@ -453,7 +453,7 @@ impl TreeSequence { /// let timestamp = prov_ref.timestamp(0).unwrap(); /// assert_eq!(timestamp, row_0.timestamp); /// use core::str::FromStr; - /// let dt_utc = humantime::Timestamp::from_str(×tamp).unwrap(); + /// let dt_utc = chrono::DateTime::::from_str(×tamp).unwrap(); /// println!("utc = {}", dt_utc); /// # } /// ``` @@ -464,7 +464,7 @@ impl TreeSequence { expected: "provenance record".to_string(), }); } - let timestamp = humantime::format_rfc3339(std::time::SystemTime::now()).to_string(); + let timestamp = chrono::Utc::now().to_string(); let rv = unsafe { ll_bindings::tsk_provenance_table_add_row( &mut (*self.inner.as_ref().tables).provenances,