File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -188,20 +188,17 @@ fn uptime_with_file(file_path: &OsString) -> UResult<()> {
188
188
fn uptime_since ( ) -> UResult < ( ) > {
189
189
#[ cfg( unix) ]
190
190
#[ cfg( not( target_os = "openbsd" ) ) ]
191
- let ( boot_time, _) = process_utmpx ( None ) ;
192
-
193
- #[ cfg( target_os = "openbsd" ) ]
194
- let uptime = get_uptime ( None ) ?;
195
- #[ cfg( unix) ]
196
- #[ cfg( not( target_os = "openbsd" ) ) ]
197
- let uptime = get_uptime ( boot_time) ?;
198
- #[ cfg( target_os = "windows" ) ]
191
+ let uptime = {
192
+ let ( boot_time, _) = process_utmpx ( None ) ;
193
+ get_uptime ( boot_time) ?
194
+ } ;
195
+ #[ cfg( any( windows, target_os = "openbsd" ) ) ]
199
196
let uptime = get_uptime ( None ) ?;
200
197
201
- let initial_date = Local
198
+ let since_date = Local
202
199
. timestamp_opt ( Utc :: now ( ) . timestamp ( ) - uptime, 0 )
203
200
. unwrap ( ) ;
204
- println ! ( "{}" , initial_date . format( "%Y-%m-%d %H:%M:%S" ) ) ;
201
+ println ! ( "{}" , since_date . format( "%Y-%m-%d %H:%M:%S" ) ) ;
205
202
206
203
Ok ( ( ) )
207
204
}
You can’t perform that action at this time.
0 commit comments