template::widget::h5time (public)
template::widget::h5time element_reference tag_attributes
Defined in packages/acs-templating/tcl/date-procs.tcl
Implements the HTML 5 input type "time". Supported element parameters: "-min" and "-max": for setting minimum and maximum times that can be chosen by the user. If used, the condition min <= value <= max must be met. (Format = "hh:mm" or "hh:mm:ss" if parameter "-step" is present) "-step": integer value that equates to the number of seconds you want to increment by Parameters supplied this way will supersede same-named parameters supplied through the "-html" switch. This widget also adds the attribute "pattern" as fallback for browsers which do not support input type="time".
- Parameters:
- element_reference (required)
- tag_attributes (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: upvar $element_reference element set attributes [::template::widget::merge_tag_attributes element $tag_attributes] # Add fallback pattern attribute (HH:MM:SS) dict set attributes pattern {(2[0-4]|[0-1][0-9]):[0-5][0-9]:[0-5][0-9]} # A HTML time field will always return a value in 24-hour format # including leading zeros (hh:mm), regardless of the input # format. If the step attribute is used time always includes # seconds (hh:mm:ss). However, on the server side we must be able # to accept and process both formats, so we must check for both. set clock_formats { "%H:%M" "%H:%M:%S" } # check min/max constraint set last_time "" foreach d {max value min} { if {[info exists element($d)] && $element($d) ne ""} { set attr_value $element($d) } elseif {[dict exists attributes $d] && [dict get $attributes $d] ne ""} { set attr_value [dict get $attributes $d] } else { continue } foreach clock_format $clock_formats { set invalid_time_p [catch { set current_time [clock scan $attr_value -format $clock_format] }] if {!$invalid_time_p} { break } } if {!$invalid_time_p} { if {$last_time ne "" && $current_time > $last_time} { ns_log Warning "template::widget::h5time value of attribute \"$d\" $attr_value too big" } else { dict set attributes $d $attr_value } set last_time $current_time } else { ns_log Warning "template::widget::h5time value of attribute \"$d\" $attr_value is not a correct time" } } if {[info exists element(step)]} { if {[string is integer -strict $element(step)]} { dict set attributes step $element(step) } else { ns_log Warning {template::widget::h5time value of attribute "step" is not an integer!} } } return [template::widget::input time element $attributes]XQL Not present: Generic, PostgreSQL, Oracle