Forum OpenACS Q&A: Response to datetime to "Nice Dates"

Posted by Michael A. Cleverly on
The pretty_pg_date procedure as it stands above works fine with the example postgres date (in the original message) if and only if you are running the Tcl 8.2+ version of AOLserver. (In other words, nsd is linked to nsd8x, or you run nsd8x directly.)

The clock command does in fact exist in Tcl 7.6 (where it made it's original debut) but the 7.6 version does not know how to interpret a postgres style date. (Guess I should have verified it on both versions of nsd before posting... 😊

To make the procedure work on either nsd76 or nsd8x, add the following snipet of code above the call to clock scan:

# Tcl 7.6 does not know how to deal with a "YYYY-MM-DD ..." type of date like 8.2 does
if {[string compare [info tclversion] 7.6] == 0} {
    regsub {^([12][0-9][0-9][0-9])-([01][0-9])-([0-3][0-9])} $pg_date {//} pg_date