summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2022-04-15 11:48:07 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2022-04-15 15:45:32 +0100
commit91ad8282399da7f3cabcb62123d89c70fb158182 (patch)
treed32b7eab7033eca2a23dd543fc12af66f119644c
parent28417c51e8a75099911aa4612483f79aaeb9f167 (diff)
downloadsubplot-91ad8282399da7f3cabcb62123d89c70fb158182.tar.gz
(subplotlib): Remove dependency on chrono
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r--Cargo.lock17
-rw-r--r--subplotlib/Cargo.toml2
-rw-r--r--subplotlib/src/steplibrary/files.rs11
3 files changed, 12 insertions, 18 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 2ee9189..f07e9ba 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -118,7 +118,6 @@ dependencies = [
"libc",
"num-integer",
"num-traits",
- "time 0.1.43",
"winapi",
]
@@ -382,7 +381,7 @@ dependencies = [
"proc-macro2",
"quote",
"syn",
- "time 0.3.9",
+ "time",
]
[[package]]
@@ -1193,7 +1192,7 @@ dependencies = [
"tempfile-fast",
"tera",
"thiserror",
- "time 0.3.9",
+ "time",
"walkdir",
]
@@ -1220,7 +1219,6 @@ name = "subplotlib"
version = "0.1.1"
dependencies = [
"base64",
- "chrono",
"fehler",
"filetime",
"fs2",
@@ -1234,6 +1232,7 @@ dependencies = [
"subplot-build",
"subplotlib-derive",
"tempfile",
+ "time",
"unescape",
]
@@ -1365,16 +1364,6 @@ dependencies = [
[[package]]
name = "time"
-version = "0.1.43"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
-dependencies = [
- "libc",
- "winapi",
-]
-
-[[package]]
-name = "time"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd"
diff --git a/subplotlib/Cargo.toml b/subplotlib/Cargo.toml
index ed3fb8a..554b454 100644
--- a/subplotlib/Cargo.toml
+++ b/subplotlib/Cargo.toml
@@ -22,7 +22,7 @@ base64 = "0.13"
state = "0.5"
tempfile = "3.1"
fs2 = "0.4"
-chrono = "0.4"
+time = { version = "0.3", features = ["parsing"] }
filetime = "0.2"
regex = "1.4"
shell-words = "1.0"
diff --git a/subplotlib/src/steplibrary/files.rs b/subplotlib/src/steplibrary/files.rs
index 991cd88..1a55f7a 100644
--- a/subplotlib/src/steplibrary/files.rs
+++ b/subplotlib/src/steplibrary/files.rs
@@ -10,9 +10,10 @@ use std::io::{self, Write};
use std::path::PathBuf;
use std::time::{Duration, SystemTime};
-use chrono::{TimeZone, Utc};
use filetime::FileTime;
use regex::Regex;
+use time::macros::format_description;
+use time::OffsetDateTime;
pub use crate::prelude::*;
@@ -86,8 +87,12 @@ pub fn create_from_embedded_with_other_name(
/// If the file does not exist, it will be created.
#[step]
pub fn touch_with_timestamp(context: &Datadir, filename: &str, mtime: &str) {
- let ts = Utc.datetime_from_str(mtime, "%Y-%m-%d %H:%M:%S")?;
- let (secs, nanos) = (ts.timestamp(), ts.timestamp_subsec_nanos());
+ let fd = format_description!(
+ "[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour]:[offset_minute]"
+ );
+ let full_time = format!("{} +00:00", mtime);
+ let ts = OffsetDateTime::parse(&full_time, &fd)?;
+ let (secs, nanos) = (ts.unix_timestamp(), 0);
let mtime = FileTime::from_unix_time(secs, nanos);
let full_path = context.canonicalise_filename(filename)?;
// If the file doesn't exist, create it