Skip to content

Commit 82bef1f

Browse files
author
Naseschwarz
committed
Move from NaiveDateTime to DateTime fcts
1 parent b134c81 commit 82bef1f

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/components/utils/logitems.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use asyncgit::sync::{CommitId, CommitInfo};
2-
use chrono::{DateTime, Duration, Local, NaiveDateTime, Utc};
2+
use chrono::{DateTime, Duration, Local, Utc};
33
use indexmap::IndexSet;
44
use std::{rc::Rc, slice::Iter};
55

@@ -67,11 +67,7 @@ impl LogEntry {
6767
pub fn timestamp_to_datetime(
6868
time: i64,
6969
) -> Option<DateTime<Local>> {
70-
let date = NaiveDateTime::from_timestamp(time, 0);
71-
72-
Some(DateTime::<Local>::from(
73-
DateTime::<Utc>::from_naive_utc_and_offset(date, Utc),
74-
))
70+
Some(DateTime::<_>::from(DateTime::from_timestamp(time, 0)?))
7571
}
7672

7773
///

src/popups/file_revlog.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use asyncgit::{
1818
AsyncDiff, AsyncGitNotification, DiffParams, DiffType,
1919
};
2020
use asyncgit::{AsyncFileHistoryJob, FileHistoryEntry};
21-
use chrono::{DateTime, Duration, Local, NaiveDateTime, Utc};
21+
use chrono::{DateTime, Duration, Local};
2222
use crossbeam_channel::Sender;
2323
use crossterm::event::Event;
2424
use ratatui::{
@@ -281,11 +281,7 @@ impl FileRevlogPopup {
281281
pub fn timestamp_to_datetime(
282282
time: i64,
283283
) -> Option<DateTime<Local>> {
284-
let date = NaiveDateTime::from_timestamp(time, 0);
285-
286-
Some(DateTime::<Local>::from(
287-
DateTime::<Utc>::from_naive_utc_and_offset(date, Utc),
288-
))
284+
Some(DateTime::<_>::from(DateTime::from_timestamp(time, 0)?))
289285
}
290286

291287
fn get_rows(&self, now: DateTime<Local>) -> Vec<Row> {

0 commit comments

Comments
 (0)