1758595 Members
1976 Online
108872 Solutions
New Discussion юеВ

change time man page

 
TTr
Honored Contributor

Re: change time man page

I see. You want to count seconds using base 10, where the time format uses base 60. Well you have to convert ot base 10 as you mentioned.
Bill Hassell
Honored Contributor

Re: change time man page

While the man page says seconds, if you saw some time output like this:

real 45296.7
user 5678.9
sys 1744.0

would it be more useful? By common convention, the ":" character separates hours, minutes and seconds. Of course, there may be a different method used in a different country or language (see man environ, specifically LC_TIME). The time program always shows seconds until 59.9, then shows mins:secs until 59:59.9 and then shows hrs:mins:secs. Computers are quite happy with 45296.7 but humans are more comfortable with 12:34:56.7


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: change time man page

Hi Brem:

To add to Bill's discussion, here's a little Perl snippet to convert a time format of H:M:S.f to seconds:

# TIME=12:34:56.7
# echo ${TIME} | perl -nle '@t=reverse split /:/;for (1,60,3600) {$sec+=$t[$i]*$_;$i++};END{print $sec}'
45296.7

This works equally well for only minutes and seconds, too, like:

# TIME=3:11.8
# echo ${TIME} | perl ...
191.8

Regards!

...JRF...
Regards!

...JRF...