Mercurial > hg > egg-tcls
comparison 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 |
comparison
equal
deleted
inserted
replaced
638:5260156d9521 | 639:c11ee9fea4b8 |
---|---|
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 proc tj_ctime {ustamp} { | 118 proc tj_ctime {ustamp} { |
119 return [clock format $ustamp -format [tj_qm "datefmt"]] | 119 return [clock format $ustamp -format [tj_qm "datefmt_long"]] |
120 } | |
121 | |
122 | |
123 proc tj_ctimes {ustamp} { | |
124 return [clock format $ustamp -format [tj_qm "datefmt_short"]] | |
120 } | 125 } |
121 | 126 |
122 | 127 |
123 # ------------------------------------------------------------------------ | 128 # ------------------------------------------------------------------------ |
124 proc tj_str_append { qlist qvalue qsingular qplural } { | 129 proc tj_str_append { qlist qvalue qsingular qplural } { |
160 | 165 |
161 return $ustr | 166 return $ustr |
162 } | 167 } |
163 | 168 |
164 | 169 |
165 proc tj_get_tj_str_delta { ustamp } { | 170 proc tj_get_tj_str_delta {ustamp uclock} { |
166 set udelta [expr $ustamp - [clock seconds]] | 171 set udelta [expr $ustamp - $uclock] |
167 | 172 |
168 if {$udelta < 0} { | 173 if {$udelta < 0} { |
169 set ufmt "tj_past" | 174 set ufmt "tjs_past" |
170 set useconds [expr -$udelta] | 175 set useconds [expr -$udelta] |
171 } else { | 176 } else { |
172 set ufmt "tj_remaining" | 177 set ufmt "tjs_future" |
173 set useconds $udelta | 178 set useconds $udelta |
174 } | 179 } |
175 | 180 |
176 # return [utl_str_map_values [tj_qm $ufmt] [list ]] | 181 return [utl_str_map_values [tj_qm $ufmt] [list [tj_get_tj_str $useconds] [tj_ctime $ustamp]]] |
177 return [tj_get_tj_str $useconds] | |
178 } | 182 } |
179 | 183 |
180 | 184 |
181 # ------------------------------------------------------------------------ | 185 # ------------------------------------------------------------------------ |
182 proc tj_display_tjs {upublic unick uchan uname uid uclock} { | 186 proc tj_display_tjs {upublic unick uchan uname uid uclock} { |
380 tj_log "$uerrmsg on SQL:\n$usql" | 384 tj_log "$uerrmsg on SQL:\n$usql" |
381 return 1 | 385 return 1 |
382 } | 386 } |
383 } | 387 } |
384 | 388 |
385 tj_msg $upublic $unick $uchan "tj_updated" [list $cid $uid $uhand $rdesc $udate $utjstr] | 389 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' AND uid LIKE '[utl_escape $uid]'" |
386 tj_log "tj_updated $cid:$uid:$uhand:$rdesc:$rdate:$udate" | 390 tj_dbh eval $usql { |
391 set utjstr [tj_get_tj_str_delta [utl_sql_datetime_to_stamp $utarget] $uclock] | |
392 tj_msg $upublic $unick $uchan "tj_updated" [list $id $uid $uhand $udesc $udate $utjstr] | |
393 tj_log "tj_updated $id:$uid:$uhand:$udesc:$utarget" | |
394 } | |
387 } | 395 } |
388 | 396 |
389 } elseif {[tj_cmd_match "remind" $rcmd]} { | 397 } elseif {[tj_cmd_match "remind" $rcmd]} { |
390 # !tj remind #<id> <<dd.mm.yyyy [hh:mm]>|<message>> | 398 # !tj remind #<id> <<dd.mm.yyyy [hh:mm]>|<message>> |
391 # !tj remind #<id> <<dd.mm [hh:mm]>|<message>> | 399 # !tj remind #<id> <<dd.mm [hh:mm]>|<message>> |
412 | 420 |
413 set nitem 0 | 421 set nitem 0 |
414 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' ORDER BY ucreated" | 422 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' ORDER BY ucreated" |
415 tj_dbh eval $usql { | 423 tj_dbh eval $usql { |
416 incr nitem | 424 incr nitem |
417 set ustamp [utl_sql_datetime_to_stamp $utarget] | 425 set qtarget [utl_sql_datetime_to_stamp $utarget] |
418 tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $ustamp] $uid $udesc] | 426 set ustr [tj_get_tj_str_delta $qtarget $uclock] |
427 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] | |
419 } | 428 } |
420 | 429 |
421 if {!$nitem} { | 430 if {!$nitem} { |
422 tj_msg $upublic $unick $uchan "no_results" [list $uname] | 431 tj_msg $upublic $unick $uchan "no_results" [list $uname] |
423 } | 432 } |