# HG changeset patch # User Matti Hamalainen # Date 1483840335 -7200 # Node ID 880a07485275422f96a79c1c2d4de96f79723789 # Parent 0f7524550aa2658c7db180991678528378889177 Add utl_ctime() to utillib and use it elsewhere. diff -r 0f7524550aa2 -r 880a07485275 feeds.tcl --- a/feeds.tcl Sun Jan 08 01:44:19 2017 +0200 +++ b/feeds.tcl Sun Jan 08 03:52:15 2017 +0200 @@ -19,6 +19,9 @@ ### you wish. See "config.feeds.example" for an example config file. source [file dirname [info script]]/config.feeds +### Required utillib.tcl +source [file dirname [info script]]/utillib.tcl + ########################################################################## # No need to look below this line @@ -57,13 +60,6 @@ } } -proc feeds_ctime {utime} { - if {$utime == "" || $utime == "*"} { - set utime 0 - } - return [clock format $utime -format "%d.%m.%Y %H:%M"] -} - ### Open database, etc if {[catch {sqlite3 feeds_dbh $feeds_dbfile} uerrmsg]} { diff -r 0f7524550aa2 -r 880a07485275 fetch_feeds.tcl --- a/fetch_feeds.tcl Sun Jan 08 01:44:19 2017 +0200 +++ b/fetch_feeds.tcl Sun Jan 08 03:52:15 2017 +0200 @@ -10,14 +10,15 @@ # This script is freely distributable under GNU GPL (version 2) license. # ############################################################################## -package require sqlite3 -source [file dirname [info script]]/utillib.tcl ### The configuration should be in config.feeds in same directory ### as this script. Or change the line below to point where ever ### you wish. See "config.feeds.example" for an example config file. source [file dirname [info script]]/config.feeds +### Required utillib.tcl +source [file dirname [info script]]/utillib.tcl + ############################################################################## diff -r 0f7524550aa2 -r 880a07485275 quotedb.tcl --- a/quotedb.tcl Sun Jan 08 01:44:19 2017 +0200 +++ b/quotedb.tcl Sun Jan 08 03:52:15 2017 +0200 @@ -48,13 +48,6 @@ } } -proc qdb_ctime {utime} { - if {$utime == "" || $utime == "*"} { - set utime 0 - } - - return [clock format $utime -format "%d.%m.%Y %H:%M"] -} proc qdb_msg_do {apublic anick achan amsg} { global qdb_preferredmsg @@ -361,7 +354,7 @@ set usql "SELECT id AS quoteID, utime AS utime, utext AS utext, user AS uuser FROM $utable $fquery ORDER BY utime DESC LIMIT $ulimit" qdb_handle eval $usql { incr uresults - qdb_msg $upublic $unick $uchan $qdb_msg_search_fmt [list $quoteID $utext $uuser $utime [qdb_ctime $utime]] + qdb_msg $upublic $unick $uchan $qdb_msg_search_fmt [list $quoteID $utext $uuser $utime [utl_ctime $utime]] } if {$uresults == 0} { diff -r 0f7524550aa2 -r 880a07485275 urllog.tcl --- a/urllog.tcl Sun Jan 08 01:44:19 2017 +0200 +++ b/urllog.tcl Sun Jan 08 03:52:15 2017 +0200 @@ -106,14 +106,6 @@ } -proc urllog_ctime {utime} { - if {$utime == "" || $utime == "*"} { - set utime 0 - } - return [clock format $utime -format "%d.%m.%Y %H:%M"] -} - - proc urllog_isnumber {uarg} { foreach i [split $uarg {}] { if {![string match \[0-9\] $i]} { return 0 } @@ -192,7 +184,7 @@ } else { set qstr "" } - append qstr "($uuser/$uchan@[urllog_ctime $utime])" + append qstr "($uuser/$uchan@[utl_ctime $utime])" if {[string length $utitle] > 0} { set qstr "$urlmsg_alreadyknown - '$utitle' $qstr" } else { @@ -616,7 +608,7 @@ if {$urllog_shorturl != 0 && $uid != ""} { set shortURL "$shortURL [urllog_get_short $uid]" } - urllog_msg $upublic $unick $uchan "#$iresults: $shortURL ($uuser@[urllog_ctime $utime])" + urllog_msg $upublic $unick $uchan "#$iresults: $shortURL ($uuser@[utl_ctime $utime])" } if {$iresults == 0} { diff -r 0f7524550aa2 -r 880a07485275 utillib.tcl --- a/utillib.tcl Sun Jan 08 01:44:19 2017 +0200 +++ b/utillib.tcl Sun Jan 08 03:52:15 2017 +0200 @@ -63,6 +63,14 @@ } +proc utl_ctime {utime} { + if {$utime == "" || $utime == "*"} { + set utime 0 + } + return [clock format $utime -format "%d.%m.%Y %H:%M"] +} + + ### ### SQL database handling ###