Mercurial > hg > egg-tcls
changeset 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 | 4dbad81bfdd9 |
files | config.tj.example tj.tcl |
diffstat | 2 files changed, 26 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/config.tj.example Tue Feb 16 12:30:07 2021 +0200 +++ b/config.tj.example Tue Feb 16 12:31:17 2021 +0200 @@ -69,7 +69,8 @@ ### array set tj_messages { - "datefmt" "%d.%m.%Y %H:%M" + "datefmt_long" "%d.%m.%Y %H:%M" + "datefmt_short" "%d.%m.%Y" "help_full" {"help" "help_set" "help_list" "help_delete"} "help" "@cmd@ \[#<id>\] \[nimi\]" @@ -105,8 +106,11 @@ "tj_str_sep" ", " "tj_str_sep_last" " ja " - "tj_remaining" "@1@:llä on @3@ jäljellä @2@ (@4@)." + "tj_future" "@1@:llä on @3@ jäljellä @2@ (@4@)." "tj_past" "@1@ on ollut @2@-reservissä @3@ (@4@)." + "tjs_future" "jäljellä @1@" + "tjs_past" "kulunut @1@" + "tj_not_set" "@1@:n @2@-TJ:tä ei ole asetettu." }
--- 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} {