crabmail

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

commit 24aa2f0fa88c2fc0738f4543f32335b326d8273a
parent 764a63707126dc0ab3d2833fadb0313de21ea75a
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed, 22 Dec 2021 14:54:28 -0800

add format, tests

Diffstat:
Mcrabmail.conf | 1+
Msrc/time.rs | 13+++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/crabmail.conf b/crabmail.conf @@ -2,3 +2,4 @@ list_email=crabmail@flounder.online list_name=Crabmail Mailing List url=https://lists.flounder.online/crabmail homepage=https://crabmail.flounder.online/ +ok_attachments=text/*, diff --git a/src/time.rs b/src/time.rs @@ -22,6 +22,15 @@ pub struct Date { second: u32, } +impl Date { + fn ymd(&self) -> String { + format!( + "{:04}-{:02}-{:02}", + self.year, self.month, self.day_of_month + ) + } +} + // 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 @@ -137,7 +146,7 @@ mod tests { #[test] fn test_date_conversion() { - println!("{:?}", secs_to_date(1640211435)); - println!("{:?}", secs_to_date(1641321435)) + assert_eq!("2021-12-22", secs_to_date(1640211435).ymd()); + assert_eq!("2022-01-04", secs_to_date(1641321435).ymd()) } }