crabmail

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

commit 2ee35058ef5496f89e80e1301b35cd468ef2eede
parent 24aa2f0fa88c2fc0738f4543f32335b326d8273a
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed, 22 Dec 2021 15:01:49 -0800

move from relative to absolute times

this has some problems (time zones: I don't want to do localization)

but it works better for static HTML

Diffstat:
Msrc/main.rs | 2+-
Msrc/time.rs | 3++-
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -172,7 +172,7 @@ impl<'a> ThreadList<'a> { } span(class="timeago") { - : format!(" | {} replies | {}", thread.messages.len() - 1, time::timeago(thread.last_reply())) + : format!(" | {} replies | {}", thread.messages.len() - 1, time::secs_to_date(thread.last_reply()).ymd()) } } } diff --git a/src/time.rs b/src/time.rs @@ -23,7 +23,7 @@ pub struct Date { } impl Date { - fn ymd(&self) -> String { + pub fn ymd(&self) -> String { format!( "{:04}-{:02}-{:02}", self.year, self.month, self.day_of_month @@ -34,6 +34,7 @@ impl Date { // 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 +// UTC // TODO handle 64-bit overflow pub fn secs_to_date(unixtime: u64) -> Date { let secs = unixtime as i64 - LEAP_EPOCH;