changeset 422:880a07485275

Add utl_ctime() to utillib and use it elsewhere.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 08 Jan 2017 03:52:15 +0200
parents 0f7524550aa2
children 44c9128097cd
files feeds.tcl fetch_feeds.tcl quotedb.tcl urllog.tcl utillib.tcl
diffstat 5 files changed, 17 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- 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]} {
--- 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
+
 
 ##############################################################################
 
--- 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} {
--- 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} {
--- 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
 ###