proc now {{what all}} {
set time [ns_localtime]
switch $what {
all {return [format "%04d-%02d-%02d %02d:%02d:%02d" [expr [lindex $time 5] + 1900] [expr [lindex $time 4] + 1] [lindex $time 3] [lindex $time 2] [lindex $time 1] [lindex $time 0]]}
date {return [format "%04d-%02d-%02d" [expr [lindex $time 5] + 1900] [expr [lindex $time 4] + 1] [lindex $time 3]]}
time {return [format "%02d:%02d:%02d" [lindex $time 2] [lindex $time 1] [lindex $time 0]]}
tag {return [format "%04d%02d%02d%02d%02d%02d" [expr [lindex $time 5] + 1900] [expr [lindex $time 4] + 1] [lindex $time 3] [lindex $time 2] [lindex $time 1] [lindex $time 0]]}
}
}
proc sql_safe_string {s} {
set out ""
while {[string first "'" $s] > -1} {
set f [string first "'" $s]
append out [string range $s 0 $f]
append out "'"
set s [string range $s [expr $f + 1] end]
}
append out $s
return $out
}
|