diff options
author | boasting-squirrel <boasting.squirrel@gmail.com> | 2019-02-17 08:40:47 +0000 |
---|---|---|
committer | boasting-squirrel <boasting.squirrel@gmail.com> | 2019-02-17 08:40:47 +0000 |
commit | 6a8622e1c37cff8d32871887137954073a5a86e6 (patch) | |
tree | 77e0f2b873999c784d3d3ab06f57e4e9f83f2a55 /src | |
parent | Improved design of last-modification column (diff) | |
download | miniserve-6a8622e1c37cff8d32871887137954073a5a86e6.tar.gz miniserve-6a8622e1c37cff8d32871887137954073a5a86e6.zip |
Added docstrings
Diffstat (limited to 'src')
-rw-r--r-- | src/listing.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/listing.rs b/src/listing.rs index b985b1e..c9720fa 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -307,6 +307,11 @@ pub fn directory_listing<S>( .body(html)) } +/// Converts a SystemTime object to a strings tuple (date, time) +/// Date is formatted as %e %b, e.g. Jul 12 +/// Time is formatted as %R, e.g. 22:34 +/// +/// If no SystemTime was given, returns a tuple containing empty strings fn convert_to_utc(src_time: Option<SystemTime>) -> (String, String) { match src_time { Some(time) => { @@ -320,6 +325,11 @@ fn convert_to_utc(src_time: Option<SystemTime>) -> (String, String) { } } +/// Converts a SystemTime to a string readable by a human, +/// i.e. calculates the duration between now() and the given SystemTime, +/// and gives a rough approximation of the elapsed time since +/// +/// If no SystemTime was given, returns an empty string fn humanize_duration(src_time: Option<SystemTime>) -> String { match src_time { Some(std_time) => match SystemTime::now().duration_since(std_time) { |