Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ serde-pickle = "1.1.0"
bincode = "1.3.1"
rand = "0.8.3"
rand_distr = "0.4.0"
chrono = "0.4.19"
humantime = {version = "2.1.0"}
# chrono is out (for now) due to security issues
# chrono = "0.4.19"

[build-dependencies]
bindgen = "0.59.1"
Expand Down
16 changes: 4 additions & 12 deletions src/provenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@ assert_eq!(record_0, row_0.record);
let timestamp = prov_ref.timestamp(0).unwrap();
assert_eq!(timestamp, row_0.timestamp);

// You can get the `chrono::DateTime` object back from the `String`:

let dt = chrono::DateTime::parse_from_rfc3339(&timestamp).unwrap();

// You can get specific time types back, too:
// You can get the `humantime::Timestamp` object back from the `String`:
use core::str::FromStr;
let dt_utc = chrono::DateTime::<chrono::Utc>::from_str(&timestamp).unwrap();
let dt_local = chrono::DateTime::<chrono::Local>::from_str(&timestamp).unwrap();
println!("local = {}", dt_local);
let timestamp_string = humantime::Timestamp::from_str(&timestamp).unwrap();

// Provenance transfers to the tree sequences
let treeseq = tables.tree_sequence(tskit::TreeSequenceFlags::BUILD_INDEXES).unwrap();
Expand All @@ -77,11 +71,9 @@ let record_0 = prov_ref.record(0).unwrap();
assert_eq!(record_0, row_0.record);
let timestamp = prov_ref.timestamp(0).unwrap();
assert_eq!(timestamp, row_0.timestamp);
let dt = chrono::DateTime::parse_from_rfc3339(&timestamp).unwrap();
use core::str::FromStr;
let dt_utc = chrono::DateTime::<chrono::Utc>::from_str(&timestamp).unwrap();
let dt_local = chrono::DateTime::<chrono::Local>::from_str(&timestamp).unwrap();
println!("local = {}", dt_local);
let dt_utc = humantime::Timestamp::from_str(&timestamp).unwrap();
println!("utc = {}", dt_utc);
```

"##
Expand Down