Skip to content

Commit 8bb08be

Browse files
authored
Replace chrono dependency with humantime to avoid RUSTSEC-2020-0071 and RUSTSEC-2020-0159 (#171)
1 parent 896b589 commit 8bb08be

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ thiserror = "1.0"
2020
libc = "0.2.81"
2121
streaming-iterator = "0.1.5"
2222
bitflags = "1.2.1"
23-
chrono = {version = "0.4.19", optional = true}
23+
humantime = {version = "2.1.0", optional = true}
2424
serde = {version = "1.0.118", features = ["derive"], optional = true}
2525
serde_json = {version = "1.0.67", optional = true}
2626
bincode = {version = "1.3.1", optional = true}
@@ -29,18 +29,19 @@ tskit-derive = {version = "0.1.0", path = "tskit-derive", optional = true}
2929
[dev-dependencies]
3030
clap = "~2.33.3"
3131
serde = {version = "1.0.118", features = ["derive"]}
32-
serde-pickle = "0.6"
32+
serde-pickle = "1.1.0"
3333
bincode = "1.3.1"
3434
rand = "0.8.3"
3535
rand_distr = "0.4.0"
36+
chrono = "0.4.19"
3637

3738
[build-dependencies]
3839
bindgen = "0.59.1"
3940
cc = { version = "1.0", features = ["parallel"] }
4041
pkg-config = "0.3"
4142

4243
[features]
43-
provenance = ["chrono"]
44+
provenance = ["humantime"]
4445
derive = ["tskit-derive", "serde", "serde_json", "bincode"]
4546

4647
[package.metadata.docs.rs]

src/metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@
113113
//! // risk a `panic!`.
114114
//! impl tskit::metadata::MetadataRoundtrip for Metadata {
115115
//! fn encode(&self) -> Result<Vec<u8>, tskit::metadata::MetadataError> {
116-
//! match serde_pickle::to_vec(self, true) {
116+
//! match serde_pickle::to_vec(self, serde_pickle::SerOptions::default()) {
117117
//! Ok(v) => Ok(v),
118118
//! Err(e) => Err(tskit::metadata::MetadataError::RoundtripError{ value: Box::new(e) }),
119119
//! }
120120
//! }
121121
//!
122122
//! fn decode(md: &[u8]) -> Result<Self, tskit::metadata::MetadataError> {
123-
//! match serde_pickle::from_slice(md) {
123+
//! match serde_pickle::from_slice(md, serde_pickle::DeOptions::default()) {
124124
//! Ok(x) => Ok(x),
125125
//! Err(e) => Err(tskit::metadata::MetadataError::RoundtripError{ value: Box::new(e) }),
126126
//! }

src/table_collection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ impl crate::traits::NodeListGenerator for TableCollection {}
729729
#[cfg(any(doc, feature = "provenance"))]
730730
impl crate::provenance::Provenance for TableCollection {
731731
fn add_provenance(&mut self, record: &str) -> Result<crate::ProvenanceId, TskitError> {
732-
let timestamp = chrono::prelude::Local::now().to_rfc3339();
732+
let timestamp = humantime::format_rfc3339(std::time::SystemTime::now()).to_string();
733733
let rv = unsafe {
734734
ll_bindings::tsk_provenance_table_add_row(
735735
&mut (*self.as_mut_ptr()).provenances,

src/trees.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ impl crate::traits::NodeListGenerator for TreeSequence {}
11411141
#[cfg(any(doc, feature = "provenance"))]
11421142
impl crate::provenance::Provenance for TreeSequence {
11431143
fn add_provenance(&mut self, record: &str) -> Result<crate::ProvenanceId, TskitError> {
1144-
let timestamp = chrono::prelude::Local::now().to_rfc3339();
1144+
let timestamp = humantime::format_rfc3339(std::time::SystemTime::now()).to_string();
11451145
let rv = unsafe {
11461146
ll_bindings::tsk_provenance_table_add_row(
11471147
&mut (*self.inner.tables).provenances,

0 commit comments

Comments
 (0)