Re: calculate time span
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: calculate time span

From: Uwe Klein <uwe_klein_habertwedt@t-online.de>
Date: Mon Feb 27 2006 - 10:13:51 CET

Lisa Pearlson wrote:
> Why does it break after a year?

format specifier "%j" is day of year.
When you reach the next year ( 366+ Days)
counting starts at 1 again.

an alternate would be

set tdiff 12345678
set sec_in_day [ expr 60 * 60 * 24 ]

set days [ expr $tdiff / $sec_in_day ]
set sec_remain [ expr $tdiff % $sec_in_day ]

if {$days} {
        set tdiffstr "$days Days "
}

append tdiffstr [ clock format $sec_remain -fmt "%T" -gmt 1 ]

uwe
>
>
> "Uwe Klein" <uwe_klein_habertwedt@t-online.de> wrote in message
> news:67d6d3-8m7.ln1@robert.houseofmax.de...
>
>>get the difference in seconds, see that it is positiv.
>>
>>i found it usefull to format with
>>[clock format $diff -fmt "%j Days %T" -gmt 1]
>>
>>be shure to use "-gmt 1", no timezones in differences.
>>breaks after a year/365Days.
>>
>>uwe
>
>
>
Received on Sun Apr 30 02:16:40 2006