33// For the full copyright and license information, please view the LICENSE
44// file that was distributed with this source code.
55
6+ use std:: time:: Duration ;
7+
68#[ cfg( target_os = "linux" ) ]
79use chrono:: Datelike ;
810use clap:: crate_version;
911use clap:: { Arg , ArgAction , Command } ;
1012#[ cfg( target_os = "linux" ) ]
1113use libc:: { sysconf, _SC_CLK_TCK} ;
12- use std:: process;
1314#[ cfg( target_os = "linux" ) ]
14- use std:: {
15- collections:: HashMap ,
16- fs,
17- path:: Path ,
18- time:: { Duration , SystemTime } ,
19- } ;
15+ use std:: { collections:: HashMap , fs, path:: Path , process, time:: SystemTime } ;
2016#[ cfg( target_os = "linux" ) ]
2117use uucore:: utmpx:: Utmpx ;
2218use uucore:: { error:: UResult , format_usage, help_about, help_usage} ;
@@ -99,7 +95,11 @@ fn fetch_idle_time(tty: String) -> Result<Duration, std::io::Error> {
9995 }
10096}
10197
102- #[ cfg( target_os = "linux" ) ]
98+ #[ cfg( not( target_os = "linux" ) ) ]
99+ fn fetch_idle_time ( tty : String ) -> Result < Duration , std:: io:: Error > {
100+ Ok ( Duration :: ZERO )
101+ }
102+
103103fn format_time_elapsed (
104104 time : Duration ,
105105 old_style : bool ,
@@ -121,16 +121,14 @@ fn format_time_elapsed(
121121 t. num_seconds( ) % 60 ,
122122 if old_style { "m" } else { "" }
123123 ) )
124+ } else if old_style {
125+ Ok ( String :: new ( ) )
124126 } else {
125- if old_style {
126- Ok ( format ! ( "" ) )
127- } else {
128- Ok ( format ! (
129- "{}.{:02}s" ,
130- t. num_seconds( ) % 60 ,
131- ( t. num_milliseconds( ) % 1000 ) / 10
132- ) )
133- }
127+ Ok ( format ! (
128+ "{}.{:02}s" ,
129+ t. num_seconds( ) % 60 ,
130+ ( t. num_milliseconds( ) % 1000 ) / 10
131+ ) )
134132 }
135133}
136134
0 commit comments