fix new clippy warnings

This commit is contained in:
extrawurst 2022-11-14 14:06:43 +01:00
parent 5430a4d21d
commit 45d850e8ca
2 changed files with 15 additions and 6 deletions

View file

@ -22,11 +22,18 @@ pub struct LogEntry {
impl From<CommitInfo> for LogEntry {
fn from(c: CommitInfo) -> Self {
let time =
let hash_short = c.id.get_short_string().into();
let time = {
let date = NaiveDateTime::from_timestamp_opt(c.time, 0);
if date.is_none() {
log::error!("error reading commit date: {hash_short} - timestamp: {}",c.time);
}
DateTime::<Local>::from(DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp(c.time, 0),
date.unwrap_or_default(),
Utc,
));
))
};
let author = c.author;
#[allow(unused_mut)]
@ -40,7 +47,7 @@ impl From<CommitInfo> for LogEntry {
author: author.into(),
msg: msg.into(),
time,
hash_short: c.id.get_short_string().into(),
hash_short,
id: c.id,
}
}
@ -56,7 +63,7 @@ impl LogEntry {
format!("{:0>2}m ago", delta.num_minutes())
};
format!("{delta_str: <10}")
} else if self.time.date() == now.date() {
} else if self.time.date_naive() == now.date_naive() {
self.time.format("%T ").to_string()
} else {
self.time.format("%Y-%m-%d").to_string()

View file

@ -26,9 +26,11 @@ macro_rules! try_or_popup {
/// helper func to convert unix time since epoch to formated time string in local timezone
pub fn time_to_string(secs: i64, short: bool) -> String {
let time = DateTime::<Local>::from(DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp(secs, 0),
NaiveDateTime::from_timestamp_opt(secs, 0)
.unwrap_or_default(),
Utc,
));
time.format(if short {
"%Y-%m-%d"
} else {