summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-29 13:01:17 +0200
committerLars Wirzenius <liw@liw.fi>2022-02-02 16:26:50 +0200
commitc41710433925fbf945417c42f03d1f08b98fe4fa (patch)
treeab67b54409a1fc3b0a326cb319b440a8cf2f4fba /src
parent16a97d690a9e6f523f6390acc3813e1fb55b44a1 (diff)
downloadsubplot-c41710433925fbf945417c42f03d1f08b98fe4fa.tar.gz
chore: rewrite use of chorno crate to use just time crate
Also, sort the dependency list in Cargo.toml so it's tidy. Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r--src/bin/subplot.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs
index 3353328..6028f76 100644
--- a/src/bin/subplot.rs
+++ b/src/bin/subplot.rs
@@ -3,12 +3,12 @@
use anyhow::Result;
-use chrono::{Local, TimeZone};
use structopt::StructOpt;
use subplot::{
codegen, load_document, load_document_with_pullmark, resource, DataFile, Document, MarkupOpts,
Style,
};
+use time::{format_description::FormatItem, macros::format_description, OffsetDateTime};
use tracing::{event, instrument, span, Level, Subscriber};
use std::convert::TryFrom;
@@ -374,9 +374,12 @@ impl Docgen {
}
fn mtime_formatted(mtime: (u64, u32)) -> String {
+ const DATE_FORMAT: &[FormatItem<'_>] =
+ format_description!("[year]-[month]-[day] [hour]:[minute]");
+
let secs: i64 = format!("{}", mtime.0).parse().unwrap_or(0);
- let dt = Local.timestamp(secs, mtime.1);
- dt.format("%Y-%m-%d %H:%M").to_string()
+ let time = OffsetDateTime::from_unix_timestamp(secs).unwrap();
+ time.format(DATE_FORMAT).unwrap()
}
fn need_output(doc: &mut subplot::Document, template: &str, output: &Path) -> bool {