crabmail

Static HTML email archive viewer in Rust
git clone git://git.alexwennerberg.com/crabmail
Log | Files | Refs | README | LICENSE

commit d53bf3b03a49a3f14db787b3a78e20e50eb4d81a
parent 0028cf938e4daa2b320945b49ae0f3d84a11b778
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat,  8 Jan 2022 11:07:25 -0800

add generate time to footer

Diffstat:
Msrc/config.rs | 2++
Msrc/main.rs | 3++-
Msrc/time.rs | 7+++++++
3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/config.rs b/src/config.rs @@ -12,6 +12,7 @@ pub struct Config { pub out_dir: PathBuf, pub relative_times: bool, pub include_raw: bool, + pub now: String, } // TODO list-specific config @@ -51,6 +52,7 @@ impl Config { out_dir: PathBuf::from(""), relative_times: false, include_raw: false, + now: crate::time::current_time_rfc3339(), }) } } diff --git a/src/main.rs b/src/main.rs @@ -72,7 +72,8 @@ fn layout(page_title: impl Render, content: impl Render) -> impl Render { } hr; div(class="footer") { - : Raw("Archive generated with <a href='https://crabmail.flounder.online/'>crabmail</a>") + : Raw("Archive generated with <a href='https://crabmail.flounder.online/'>crabmail</a> at "); + : &Config::global().now; } } } diff --git a/src/time.rs b/src/time.rs @@ -38,6 +38,13 @@ impl Date { } } +pub fn current_time_rfc3339() -> String { + let current_time = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs(); + return secs_to_date(current_time).rfc3339(); +} // from http://git.musl-libc.org/cgit/musl/tree/src/time/__secs_to_tm.c // with a slightly different API // this is a line-for-line copy, not idiomatic rust