Wapp

clock format in static compiled wapptclsh?
Login

clock format in static compiled wapptclsh?

(1) By Matthias Teege (mteege) on 2018-11-16 08:07:09 [source]

I have a small project where I can use wapp. I've compiled wapptclsh and then tried to execute the following programm:

#!/usr/bin/env wapptclsh                                                                                                                  
package require wapp

proc wapp-default {} {
  wapp-trim {
    [clock format [clock seconds] -format %Y-%m-%d]
  }                                                                                                                                       
}                                                                                                                                         
wapp-start $argv

That fails with:

invalid command name "::tcl::clock::format"
    while executing
"clock format [clock seconds] -format %Y-%m-%d"
    invoked from within
"subst -novariables {[clock format [clock seconds] -format %Y-%m-%d]}"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [list subst -novariables $txt]"
    (procedure "wapp-trim" line 5)
    invoked from within
"wapp-trim {
    [clock format [clock seconds] -format %Y-%m-%d]
  }"                                                                                                                                      
    (procedure "wapp-default" line 2)
    invoked from within
"wapp-default"

It looks like the clock::format command is not available in the static Tcl interpreter. I think I can use the date and time functions from sqlite3 but that "feels" wrong.

Is it possible to make this function available? Is there a better way to make the date calculations?

Matthias

(2) By anonymous on 2022-08-27 21:16:15 in reply to 1 [link] [source]

As you note, clock type functionality is available via Sqlite. The clock command in Tcl requires loading a script several thousand lines long. This would impose extra work on Wapptclsh every time it is invoked in CGI mode. The current arrangement is aimed at making Wapptclsh startup very fast and efficient. You can get the clock functionality if mandatory by using tclsh instead of wapptclsh to run wapp.tcl.