Index: openacs-4/packages/acs-templating/tcl/date-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/date-procs.tcl,v
diff -u -r1.37.2.2 -r1.37.2.3
--- openacs-4/packages/acs-templating/tcl/date-procs.tcl	3 Mar 2007 07:33:25 -0000	1.37.2.2
+++ openacs-4/packages/acs-templating/tcl/date-procs.tcl	3 Mar 2007 19:56:21 -0000	1.37.2.3
@@ -1011,7 +1011,7 @@
   # the user to enter a freeform format
   append output "<input type=\"hidden\" name=\"$element(name).format\" "
   append output "value=\"$element(format)\" />\n"
-  append output "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\">\n<tbody><tr>"
+  append output "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\">\n"
 
   # Prepare the value to set defaults on the form
   if { [info exists element(value)] && 
@@ -1035,6 +1035,7 @@
        set id_attr_name $attributes(id)
   }
 
+  set tbody_content "<tbody><tr>"
   while { ![string equal $format_string {}] } {
 
     # Snip off the next token
@@ -1044,7 +1045,7 @@
     regexp -nocase $template::util::date::token_exp $word \
           match token type
 
-    append output "<td nowrap=\"nowrap\">"
+    append tbody_content "<td nowrap=\"nowrap\">"
     
     lappend tokens $token
 
@@ -1053,10 +1054,10 @@
     set fragment [lindex $fragment_def 1]
 
     if {[exists_and_not_null id_attr_name]} {
-           set attributes(id) "${id_attr_name}.${fragment}"
+	set attributes(id) "${id_attr_name}.${fragment}"
     }
 
-    append output [template::widget::[lindex $fragment_def 0] \
+    append tbody_content [template::widget::[lindex $fragment_def 0] \
                      element \
                      $fragment \
                      [lindex $fragment_def 2] \
@@ -1067,27 +1068,30 @@
 
     # Output the separator
     if { [string equal $sep " "] } {
-      append output "&nbsp;"
+      append tbody_content "&nbsp;"
     } else {
-      append output "$sep"
+      append tbody_content "$sep"
     }
 
-    append output "</td>\n"
+    append tbody_content "</td>\n"
   }
 
-  append output "</tr></tbody>\n"
+  append tbody_content "</tr></tbody>\n"
 
   # Append help text under each widget, if neccessary
+  set tfoot_content ""
   if { [info exists element(help)] } {
-    append output "<tfoot><tr>" 
+      
+    append tfoot_content "<tfoot><tr>\n" 
     foreach token $tokens {
 	set fragment_def $template::util::date::fragment_widgets([string toupper $token])
 	set fragment [lindex $fragment_def 1]
-	append output "<td><label for=\"$element(name).$fragment\">[lindex $fragment_def 3]</label></td>"
+	append tfoot_content "<td><label for=\"$element(name).$fragment\">[lindex $fragment_def 3]</label></td>\n"
     }
-    append output "</tr></tfoot>\n"
+    append tfoot_content "</tr></tfoot>\n"
   } 
 
+  append output "$tfoot_content$tbody_content"
   append output "</table>\n"
 
   append output "<!-- date $element(name) end -->\n"