File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,18 @@ pub struct LogEntry {
22
22
23
23
impl From < CommitInfo > for LogEntry {
24
24
fn from ( c : CommitInfo ) -> Self {
25
- let time =
25
+ let hash_short = c. id . get_short_string ( ) . into ( ) ;
26
+
27
+ let time = {
28
+ let date = NaiveDateTime :: from_timestamp_opt ( c. time , 0 ) ;
29
+ if date. is_none ( ) {
30
+ log:: error!( "error reading commit date: {hash_short} - timestamp: {}" , c. time) ;
31
+ }
26
32
DateTime :: < Local > :: from ( DateTime :: < Utc > :: from_utc (
27
- NaiveDateTime :: from_timestamp ( c . time , 0 ) ,
33
+ date . unwrap_or_default ( ) ,
28
34
Utc ,
29
- ) ) ;
35
+ ) )
36
+ } ;
30
37
31
38
let author = c. author ;
32
39
#[ allow( unused_mut) ]
@@ -40,7 +47,7 @@ impl From<CommitInfo> for LogEntry {
40
47
author : author. into ( ) ,
41
48
msg : msg. into ( ) ,
42
49
time,
43
- hash_short : c . id . get_short_string ( ) . into ( ) ,
50
+ hash_short,
44
51
id : c. id ,
45
52
}
46
53
}
@@ -56,7 +63,7 @@ impl LogEntry {
56
63
format ! ( "{:0>2}m ago" , delta. num_minutes( ) )
57
64
} ;
58
65
format ! ( "{delta_str: <10}" )
59
- } else if self . time . date ( ) == now. date ( ) {
66
+ } else if self . time . date_naive ( ) == now. date_naive ( ) {
60
67
self . time . format ( "%T " ) . to_string ( )
61
68
} else {
62
69
self . time . format ( "%Y-%m-%d" ) . to_string ( )
Original file line number Diff line number Diff line change @@ -26,9 +26,11 @@ macro_rules! try_or_popup {
26
26
/// helper func to convert unix time since epoch to formated time string in local timezone
27
27
pub fn time_to_string ( secs : i64 , short : bool ) -> String {
28
28
let time = DateTime :: < Local > :: from ( DateTime :: < Utc > :: from_utc (
29
- NaiveDateTime :: from_timestamp ( secs, 0 ) ,
29
+ NaiveDateTime :: from_timestamp_opt ( secs, 0 )
30
+ . unwrap_or_default ( ) ,
30
31
Utc ,
31
32
) ) ;
33
+
32
34
time. format ( if short {
33
35
"%Y-%m-%d"
34
36
} else {
You can’t perform that action at this time.
0 commit comments