Forum OpenACS Development: /ds/shell X tcl page

Collapse
Posted by Iuri Sampaio on
I wrote the following script that works properly on /ds/shell but it doesn't when I run it within a .tcl page

set vigencia 2011/03/10

set vigencia [string map {/ -} [lindex $vigencia 0]]

set date2 [clock format [clock scan "1 year" -base [clock scan $vigencia]] -format %Y%m%d]

set date1 [clock format [clock scan "-1 year" -base [clock scan $date2]] -format %Y%m%d]

Any ideas?

The error is:

[14/Oct/2011:09:24:14][1332.3059506032][-default:3-] Error: GET http://172.16.1.161:8000/ba-file?
referred by ""
unable to convert date-time string "10-01-2011"
while executing
"clock scan $vigencia"
("3" arm line 5)
invoked from within
"switch $i {
3 {
# vigencia
set vigencia [string map {/ -} [lindex $element 0]]

set vigencia "[clock format [clock scan $vigencia] -forma..."
("foreach" body line 6)
invoked from within
"foreach element $elements {
#ns_log Notice "$element"

Collapse
2: Re: /ds/shell X tcl page (response to 1)
Posted by Dave Bauer on
I think you are missing some code.

set vigencia 2011/03/10
set vigencia [string map {/ -} [lindex $vigencia 0]]

Should return "2011-03-10"

Where does the string "10-01-2011" come from?

Collapse
3: Re: /ds/shell X tcl page (response to 2)
Posted by Iuri Sampaio on
What a shame!
Yes, i missed the first line.
The date was comming with the wrong format %d%m%Y.

I wrote a fix for that. Thanks Dave.

set vigencia [split $vigencia {-}]
set vigencia "[lindex $vigencia 2][lindex $vigencia 1][lindex $vigencia 0]"