Mercurial > hg > egg-tcls
changeset 357:b1e7ffeaacef
weather: Adjust time output handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 11 Dec 2015 23:13:04 +0200 |
parents | 0de6e0c2c89c |
children | e06a3f3923f5 |
files | weather.tcl |
diffstat | 1 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/weather.tcl Fri Dec 11 22:54:26 2015 +0200 +++ b/weather.tcl Fri Dec 11 23:13:04 2015 +0200 @@ -77,11 +77,6 @@ } -proc weather_ctime {utime} { - return [clock format $utime -format "%H:%M"] -} - - proc weather_valid_user {uhand} { if {$uhand != "" && $uhand != "{}" && $uhand != "*"} { return 1 @@ -149,7 +144,13 @@ set uvals(station) [lindex $udata 0] set uvals(type) [lindex $udata 1] set uvals(vtime) [lindex $udata 2] - set uvals(ctime) [weather_ctime [lindex $udata 2]] + set utime_d [expr [clock seconds] - $uvals(vtime)] + if {$utime_d < 3600} { + set uvals(ctime) [clock format $uvals(vtime) -format "%H:%M"] + } else { + set uvals(ctime) [clock format $uvals(vtime) -format "%H:%M (%D)"] + } + set uvals(temp) [lindex $udata 3] if {[lindex $udata 1] == 0} { @@ -164,6 +165,9 @@ # Transform the format list set astr "" + if {$utime_d >= 3600} { + set astr "** " + } foreach aitem $weather_msg_result { set atmp $aitem foreach {akey aval} [array get uvals] {