diff options
author | s.ivkin <109stas@gmail.com> | 2022-10-23 15:49:28 +0000 |
---|---|---|
committer | s.ivkin <109stas@gmail.com> | 2022-10-23 15:49:28 +0000 |
commit | 3e81c0835f0358fab788300b53f605b1ba63641d (patch) | |
tree | 06226517457c2b3f58e75325f9fb183ae36658b9 | |
parent | Merge pull request #940 from svenstaro/dependabot/cargo/clap_complete-4.0.3 (diff) | |
download | miniserve-3e81c0835f0358fab788300b53f605b1ba63641d.tar.gz miniserve-3e81c0835f0358fab788300b53f605b1ba63641d.zip |
Change DateTime format
-rw-r--r-- | data/style.scss | 6 | ||||
-rw-r--r-- | src/renderer.rs | 17 |
2 files changed, 7 insertions, 16 deletions
diff --git a/data/style.scss b/data/style.scss index fb76a9a..c172ae8 100644 --- a/data/style.scss +++ b/data/style.scss @@ -267,7 +267,7 @@ table thead th.size { } table thead th.date { - width: 15em; + width: 21em; } table tbody tr:nth-child(odd) { @@ -295,10 +295,6 @@ td.date-cell { justify-content: space-between; } -.at { - color: var(--at_color); -} - .history { color: var(--date_text_color); } diff --git a/src/renderer.rs b/src/renderer.rs index f53620f..d7b00ec 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}; @@ -528,9 +528,7 @@ fn entry_row( td.date-cell { @if let Some(modification_date) = convert_to_utc(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) { @@ -622,13 +620,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_utc(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, |