changeset 612:c340683d6c13

utillib: Add helper functions utl_sql_stamp_to_datetime() and utl_sql_datetime_to_stamp() for converting between UNIX timestamps and SQL datetime format.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 10 Feb 2021 11:08:26 +0200
parents 6f1d26814cc9
children ea6ebcf42b47
files utillib.tcl
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/utillib.tcl	Wed Feb 10 11:07:41 2021 +0200
+++ b/utillib.tcl	Wed Feb 10 11:08:26 2021 +0200
@@ -221,3 +221,13 @@
 proc utl_escape {str} {
   return [string map {' ''} $str]
 }
+
+
+proc utl_sql_stamp_to_datetime { ustamp } {
+  return [clock format $ustamp -format "%Y-%m-%d %H:%M:%S"]
+}
+
+
+proc utl_sql_datetime_to_stamp { ustr } {
+  return [clock scan $ustr -format "%Y-%m-%d %H:%M:%S"]
+}