|
1 | 1 | use asyncgit::sync::{CommitId, CommitInfo};
|
2 |
| -use chrono::{DateTime, Duration, Local, NaiveDateTime, Utc}; |
| 2 | +use chrono::{DateTime, Duration, Local, Utc}; |
3 | 3 | use indexmap::IndexSet;
|
4 | 4 | use std::{rc::Rc, slice::Iter};
|
5 | 5 |
|
@@ -27,7 +27,8 @@ impl From<CommitInfo> for LogEntry {
|
27 | 27 | let hash_short = c.id.get_short_string().into();
|
28 | 28 |
|
29 | 29 | let time = {
|
30 |
| - let date = NaiveDateTime::from_timestamp_opt(c.time, 0); |
| 30 | + let date = DateTime::from_timestamp(c.time, 0) |
| 31 | + .map(|d| d.naive_utc()); |
31 | 32 | if date.is_none() {
|
32 | 33 | log::error!("error reading commit date: {hash_short} - timestamp: {}",c.time);
|
33 | 34 | }
|
@@ -61,8 +62,10 @@ impl From<CommitInfo> for LogEntry {
|
61 | 62 | impl LogEntry {
|
62 | 63 | pub fn time_to_string(&self, now: DateTime<Local>) -> String {
|
63 | 64 | let delta = now - self.time;
|
64 |
| - if delta < Duration::minutes(30) { |
65 |
| - let delta_str = if delta < Duration::minutes(1) { |
| 65 | + if delta < Duration::try_minutes(30).unwrap_or_default() { |
| 66 | + let delta_str = if delta |
| 67 | + < Duration::try_minutes(1).unwrap_or_default() |
| 68 | + { |
66 | 69 | "<1m ago".to_string()
|
67 | 70 | } else {
|
68 | 71 | format!("{:0>2}m ago", delta.num_minutes())
|
|
0 commit comments