James Wilkinson <[EMAIL PROTECTED]> wrote:
>
> HOURS=`expr $CONNECT_TIME \/ 3600`
> CONNECT_TIME=`expr $CONNECT_TIME - \( $HOURS \* 3600 \)`
> MINUTES=`expr $CONNECT_TIME \/ 60`
> CONNECT_TIME=`expr $CONNECT_TIME = \( $MINUTES \* 60 \)`
> SECONDS=$CONNECT_TIME

> Erk, ugly.

You could use the POSIX arithmetic substitution, i.e.,

CONNECT_TIME=$(($MINUTES * 60))

> I looked at the manpage for date, with the intention of doing something
> like date -d 00000000.$CONNECT_TIME +%r but it didn't like the date that
> way, i guess it needs the seconds between 0 and 59.  Also, there was
> nothing about converting unix time to normal time.  I'm convinced there
> must be a tool to do this.

I used to use bc to do this until I RTFM'ed:

date -d "1970-01-01 utc 968233475 sec"

Could make an alias for this if you're going to type this frequently.

Although at the moment it's off by an hour, looks like a daylight saving
bug in date.  Time to run bug...
-- 
Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to