template::widget::date (public)
template::widget::date element_reference tag_attributes
Defined in packages/acs-templating/tcl/date-procs.tcl
Create a date entry widget according to a format string The format string should contain the following fields, separated by / \ - : . or whitespace:
Any format field may be followed by "t", in which case a text widget will be used to represent the field. the array in range_ref determines interval ranges; the keys are the date fields and the values are in form {start stop interval}
string meaning YYYY 4-digit year YY 2-digit year MM 2-digit month MON month name, short (i.e. "Jan") MONTH month name, long (i.e. "January") DD day of month HH12 12-hour hour HH24 24-hour hour MI minutes SS seconds AM am/pm flag
- Parameters:
- element_reference (required)
- tag_attributes (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: variable ::template::util::date::fragment_widgets upvar $element_reference element array set attributes [::template::widget::merge_tag_attributes element $tag_attributes] set output "<!-- date $element(name) begin -->\n" if { ! [info exists element(format)] } { set element(format) [_ acs-lang.localization-formbuilder_date_format] } # Choose a pre-selected format, if any switch -- $element(format) { long { set element(format) "YYYY/MM/DD HH24:MI:SS" } short { set element(format) "YYYY/MM/DD"} time { set element(format) "HH24:MI:SS"} american { set element(format) "MM/DD/YY"} expiration { set element(format) "MM/YY" set current_year [clock format [clock seconds] -format "%Y"] set current_year [expr {$current_year % 100}] set element(short_year_interval) [list $current_year [expr {$current_year + 10}] 1] set element(help) 1 } } # Just remember the format for now - in the future, allow # the user to enter a freeform format append output "<input type=\"hidden\" name=\"$element(name).format\" " append output "value=\"$element(format)\" >\n" # Prepare the value to set defaults on the form if { [info exists element(value)] && [template::util::date::get_property not_null $element(value)] } { set value $element(value) foreach v $value { lappend trim_value [util::trim_leading_zeros $v] } set value $trim_value } else { set value {} } # Keep taking tokens off the top of the string until out # of tokens set format_string $element(format) set tokens [list] if {[info exists attributes(id)]} { set id_attr_name $attributes(id) } while { $format_string ne {} } { # Snip off the next token regexp {([^/\-.: ]*)([/\-.: ]*)(.*)} $format_string match word sep format_string # Extract the trailing "t", if any regexp -nocase $template::util::date::token_exp $word match token type lappend tokens $token # Output the widget set fragment_def $template::util::date::fragment_widgets([string toupper $token]) set fragment [lindex $fragment_def 1] if {[info exists id_attr_name] && $id_attr_name ne ""} { set attributes(id) "${id_attr_name}.${fragment}" } set widget [template::widget::[lindex $fragment_def 0] element $fragment [lindex $fragment_def 2] $type $value $element(mode) [array get attributes]] if { [info exists element(help)] } { append output "<label for=\"$element(id).${fragment}\">[lindex $fragment_def 3] $widget</label>" } else { append output $widget } # Output the separator if {$sep eq " "} { append output " " } else { append output "$sep" } } append output "<!-- date $element(name) end -->\n" return $outputXQL Not present: Generic, PostgreSQL, Oracle