diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-01-29 13:01:17 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-02-02 16:26:50 +0200 |
commit | c41710433925fbf945417c42f03d1f08b98fe4fa (patch) | |
tree | ab67b54409a1fc3b0a326cb319b440a8cf2f4fba /src | |
parent | 16a97d690a9e6f523f6390acc3813e1fb55b44a1 (diff) | |
download | subplot-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.rs | 9 |
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 { |