From 3e81c0835f0358fab788300b53f605b1ba63641d Mon Sep 17 00:00:00 2001 From: "s.ivkin" <109stas@gmail.com> Date: Sun, 23 Oct 2022 18:49:28 +0300 Subject: Change DateTime format --- src/renderer.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src') 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) -> Option<(String, String)> { - src_time.map(DateTime::::from).map(|date_time| { - ( - date_time.format("%b %e").to_string(), - date_time.format("%R").to_string(), - ) - }) +fn convert_to_utc(src_time: Option) -> Option { + src_time + .map(DateTime::::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, -- cgit v1.2.3 From 4182913eb4d3b91f988919bc45c4d46ac8d01844 Mon Sep 17 00:00:00 2001 From: IvkinStanislav <76910130+IvkinStanislav@users.noreply.github.com> Date: Thu, 10 Nov 2022 23:30:01 +0300 Subject: Update datetime format Co-authored-by: Sven-Hendrik Haase --- src/renderer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/renderer.rs b/src/renderer.rs index d7b00ec..0577b80 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -623,7 +623,7 @@ fn page_header(title: &str, file_upload: bool, favicon_route: &str, css_route: & fn convert_to_utc(src_time: Option) -> Option { src_time .map(DateTime::::from) - .map(|date_time| date_time.format("%Y/%m/%d %H:%M:%S %:z").to_string()) + .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, -- cgit v1.2.3 From dcfc220feb0821d66f9b31b5c9b2fb477cd40120 Mon Sep 17 00:00:00 2001 From: IvkinStanislav <76910130+IvkinStanislav@users.noreply.github.com> Date: Thu, 10 Nov 2022 23:40:33 +0300 Subject: Refactoring --- src/renderer.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/renderer.rs b/src/renderer.rs index 0577b80..e4c8fcd 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -526,7 +526,7 @@ 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) " " } @@ -618,9 +618,7 @@ 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) -> Option { +fn convert_to_local(src_time: Option) -> Option { src_time .map(DateTime::::from) .map(|date_time| date_time.format("%Y-%m-%d %H:%M:%S %:z").to_string()) -- cgit v1.2.3