Mercurial > hg > egg-tcls
diff tj.tcl @ 639:c11ee9fea4b8
tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
date delta description logic for miscellaneous messages.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 16 Feb 2021 12:31:17 +0200 |
parents | 5260156d9521 |
children | 0b618c09063f |
line wrap: on
line diff
--- a/tj.tcl Tue Feb 16 12:30:07 2021 +0200 +++ b/tj.tcl Tue Feb 16 12:31:17 2021 +0200 @@ -116,7 +116,12 @@ proc tj_ctime {ustamp} { - return [clock format $ustamp -format [tj_qm "datefmt"]] + return [clock format $ustamp -format [tj_qm "datefmt_long"]] +} + + +proc tj_ctimes {ustamp} { + return [clock format $ustamp -format [tj_qm "datefmt_short"]] } @@ -162,19 +167,18 @@ } -proc tj_get_tj_str_delta { ustamp } { - set udelta [expr $ustamp - [clock seconds]] +proc tj_get_tj_str_delta {ustamp uclock} { + set udelta [expr $ustamp - $uclock] if {$udelta < 0} { - set ufmt "tj_past" + set ufmt "tjs_past" set useconds [expr -$udelta] } else { - set ufmt "tj_remaining" + set ufmt "tjs_future" set useconds $udelta } -# return [utl_str_map_values [tj_qm $ufmt] [list ]] - return [tj_get_tj_str $useconds] + return [utl_str_map_values [tj_qm $ufmt] [list [tj_get_tj_str $useconds] [tj_ctime $ustamp]]] } @@ -382,8 +386,12 @@ } } - tj_msg $upublic $unick $uchan "tj_updated" [list $cid $uid $uhand $rdesc $udate $utjstr] - tj_log "tj_updated $cid:$uid:$uhand:$rdesc:$rdate:$udate" + set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' AND uid LIKE '[utl_escape $uid]'" + tj_dbh eval $usql { + set utjstr [tj_get_tj_str_delta [utl_sql_datetime_to_stamp $utarget] $uclock] + tj_msg $upublic $unick $uchan "tj_updated" [list $id $uid $uhand $udesc $udate $utjstr] + tj_log "tj_updated $id:$uid:$uhand:$udesc:$utarget" + } } } elseif {[tj_cmd_match "remind" $rcmd]} { @@ -414,8 +422,9 @@ set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' ORDER BY ucreated" tj_dbh eval $usql { incr nitem - set ustamp [utl_sql_datetime_to_stamp $utarget] - tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $ustamp] $uid $udesc] + set qtarget [utl_sql_datetime_to_stamp $utarget] + set ustr [tj_get_tj_str_delta $qtarget $uclock] + tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $qtarget] [tj_ctimes [utl_sql_datetime_to_stamp $ucreated]] [tj_ctimes [utl_sql_datetime_to_stamp $uupdated]] $uid $udesc $ustr] } if {!$nitem} {