aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Cui <krazycavin@gmail.com>2020-09-12 21:39:46 +0000
committerKevin Cui <krazycavin@gmail.com>2020-09-12 21:39:46 +0000
commit172c6699b81d47486980624b50c2bde26f28aca0 (patch)
tree1ade6f0c500c9fd3a54250ef5e07ed238064817e
parentUpgrade to actix-web 3.0.0 (diff)
downloadminiserve-172c6699b81d47486980624b50c2bde26f28aca0.tar.gz
miniserve-172c6699b81d47486980624b50c2bde26f28aca0.zip
Show "now" when last modification time less than 11 seconds
-rw-r--r--src/renderer.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/renderer.rs b/src/renderer.rs
index 17e0119..5298f21 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -913,7 +913,13 @@ fn humanize_systemtime(src_time: Option<SystemTime>) -> Option<String> {
src_time
.and_then(|std_time| SystemTime::now().duration_since(std_time).ok())
.and_then(|from_now| Duration::from_std(from_now).ok())
- .map(|duration| HumanTime::from(duration).to_text_en(Accuracy::Rough, Tense::Past))
+ .map(|duration| {
+ if duration < Duration::seconds(11) {
+ format!("now")
+ } else {
+ HumanTime::from(duration).to_text_en(Accuracy::Rough, Tense::Past)
+ }
+ })
}
/// Renders an error on the webpage