diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2022-11-11 00:27:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 00:27:41 +0000 |
commit | 5fb6eab9466bde2d863c2f2f91aa60481cbe0d14 (patch) | |
tree | 2fa335370e29665f6d1adecc13f2e9f74652b4e1 /src/renderer.rs | |
parent | Merge pull request #956 from svenstaro/update-deps (diff) | |
parent | Refactoring (diff) | |
download | miniserve-5fb6eab9466bde2d863c2f2f91aa60481cbe0d14.tar.gz miniserve-5fb6eab9466bde2d863c2f2f91aa60481cbe0d14.zip |
Merge pull request #949 from IvkinStanislav/issue-440
Change DateTime format
Diffstat (limited to 'src/renderer.rs')
-rw-r--r-- | src/renderer.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index f53620f..e4c8fcd 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -1,7 +1,7 @@ use std::time::SystemTime; use actix_web::http::StatusCode; -use chrono::{DateTime, Utc}; +use chrono::{DateTime, Local}; use chrono_humanize::Humanize; use clap::{crate_name, crate_version, ValueEnum}; use fast_qr::{convert::svg::SvgBuilder, qr::QRCodeError, QRBuilder}; @@ -526,11 +526,9 @@ fn entry_row( } } td.date-cell { - @if let Some(modification_date) = convert_to_utc(entry.last_modification_date) { + @if let Some(modification_date) = convert_to_local(entry.last_modification_date) { span { - (modification_date.0) " " - span.at { " at " } - (modification_date.1) " " + (modification_date) " " } } @if let Some(modification_timer) = humanize_systemtime(entry.last_modification_date) { @@ -620,15 +618,10 @@ fn page_header(title: &str, file_upload: bool, favicon_route: &str, css_route: & } /// 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 -fn convert_to_utc(src_time: Option<SystemTime>) -> Option<(String, String)> { - src_time.map(DateTime::<Utc>::from).map(|date_time| { - ( - date_time.format("%b %e").to_string(), - date_time.format("%R").to_string(), - ) - }) +fn convert_to_local(src_time: Option<SystemTime>) -> Option<String> { + src_time + .map(DateTime::<Local>::from) + .map(|date_time| date_time.format("%Y-%m-%d %H:%M:%S %:z").to_string()) } /// Converts a SystemTime to a string readable by a human, |