diff options
author | Galen Guyer <galen@galenguyer.com> | 2022-06-20 22:54:31 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2022-06-20 22:56:14 -0400 |
commit | b3e6f24f97c4d262002a57ff7b5aea040a4c84d6 (patch) | |
tree | dead03e885262d40026df2e82530af44f9cb3f7a | |
parent | 0ba4f8fc438c93666b8ee3f9caec615c97a385b0 (diff) |
slightly nicer expiry formatting
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/lib/ops.rs | 18 |
3 files changed, 18 insertions, 4 deletions
@@ -117,7 +117,7 @@ dependencies = [ [[package]] name = "hancock" -version = "1.1.0" +version = "1.2.0" dependencies = [ "clap", "openssl", @@ -1,6 +1,6 @@ [package] name = "hancock" -version = "1.1.0" +version = "1.2.0" edition = "2021" diff --git a/src/lib/ops.rs b/src/lib/ops.rs index efb739a..a0eac3d 100644 --- a/src/lib/ops.rs +++ b/src/lib/ops.rs @@ -255,10 +255,24 @@ fn cert_info(crt: openssl::x509::X509) -> String { let cn = get_cn(&crt); let ex = match now.compare(crt.not_after()).unwrap() { Ordering::Greater => { - format!("{} days ago", now.diff(crt.not_after()).unwrap().days) + match now.diff(crt.not_after()).unwrap().days { + 1 => { + String::from("1 day ago") + } + d @ _ => { + format!("{} days ago", d) + } + } } Ordering::Less => { - format!("in {} days", now.diff(crt.not_after()).unwrap().days) + match now.diff(crt.not_after()).unwrap().days { + 1 => { + String::from("in 1 day") + } + d @ _ => { + format!("in {} days", d) + } + } } Ordering::Equal => String::from("right now"), }; |