template::data::validate::textdate (public)
template::data::validate::textdate value_ref message_ref
Defined in packages/acs-templating/tcl/data-procs.tcl
Validate that a submitted textdate if properly formatted.
- Parameters:
- value_ref (required)
- Reference variable to the submitted value.
- message_ref (required)
- Reference variable for returning an error message.
- Returns:
- True (1) if valid, false (0) if not.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- validate_textdate
Source code: upvar 2 $message_ref message $value_ref textdate set error_msg [list] if { [info exists textdate] && $textdate ne "" } { if { [regexp {^[0-9]{4}-[0-9]{2}-[0-9]{2}$} $textdate match] } { if { [catch { clock scan -format {%Y-%m-%d} "${textdate}" }] } { # the textdate is formatted properly the template::data::transform::textdate proc # will only return correctly formatted dates in iso format, but the date is not # valid so they have entered some info incorrectly set datelist [split $textdate "-"] set year [lindex $datelist 0] set month [::string trimleft [lindex $datelist 1] 0] set day [::string trimleft [lindex $datelist 2] 0] if { $month < 1 || $month > 12 } { lappend error_msg [_ acs-templating.Month_must_be_between_1_and_12] } else { set maxdays [template::util::date::get_property days_in_month $datelist] if { $day < 1 || $day > $maxdays } { set month_pretty [template::util::date::get_property long_month_name $datelist] if { $month == 2 } { # February has a different number of days depending on the year append month_pretty " ${year}" } lappend error_msg [_ acs-templating.lt_day_between_for_month_pretty] } } } } else { # the textdate is not formatted properly set format [::string toupper [template::util::textdate_localized_format]] lappend error_msg [_ acs-templating.lt_Dates_must_be_formatted_] } } if { [llength $error_msg] > 0 } { set message [join $error_msg {<br>}] return 0 } else { return 1 }XQL Not present: Generic, PostgreSQL, Oracle