File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -130,16 +130,19 @@ impl Api {
130130 let bios_time = ( api. time_clock_get ) ( ) ;
131131 let secs = i64:: from ( bios_time. secs ) + SECONDS_BETWEEN_UNIX_AND_NEOTRON_EPOCH ;
132132 let nsecs = bios_time. nsecs ;
133- chrono:: NaiveDateTime :: from_timestamp_opt ( secs, nsecs) . unwrap ( )
133+ chrono:: DateTime :: from_timestamp ( secs, nsecs)
134+ . unwrap ( )
135+ . naive_utc ( )
134136 }
135137
136138 /// Set the current time
137139 fn set_time ( & self , timestamp : chrono:: NaiveDateTime ) {
138140 let api = self . get ( ) ;
139- let nanos = timestamp. timestamp_nanos ( ) ;
141+ let seconds = timestamp. and_utc ( ) . timestamp ( ) ;
142+ let nanos = timestamp. and_utc ( ) . timestamp_subsec_nanos ( ) ;
140143 let bios_time = bios:: Time {
141- secs : ( ( nanos / 1_000_000_000 ) - SECONDS_BETWEEN_UNIX_AND_NEOTRON_EPOCH ) as u32 ,
142- nsecs : ( nanos % 1_000_000_000 ) as u32 ,
144+ secs : ( seconds - SECONDS_BETWEEN_UNIX_AND_NEOTRON_EPOCH ) as u32 ,
145+ nsecs : nanos,
143146 } ;
144147 ( api. time_clock_set ) ( bios_time) ;
145148 }
You can’t perform that action at this time.
0 commit comments