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 --- data/style.scss | 6 +----- 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) -> 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