ad_page_contract_filter_proc_time (public)

 ad_page_contract_filter_proc_time name time_varname

Defined in packages/acs-tcl/tcl/tcl-documentation-procs.tcl

Validates time type variables of the regular variety (that is 8:12:21 PM)

Parameters:
name
time_varname
Author:
Yonatan Feldman <yon@arsdigita.com>
Created:
25 July 2000

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_page_contract_filters ad_page_contract_filters (test acs-tcl) ad_page_contract_filter_proc_time ad_page_contract_filter_proc_time test_ad_page_contract_filters->ad_page_contract_filter_proc_time _ _ (public) ad_page_contract_filter_proc_time->_ ad_complain ad_complain (public) ad_page_contract_filter_proc_time->ad_complain

Testcases:
ad_page_contract_filters
Source code:
upvar $time_varname time

    foreach time_element { time ampm } {
        if { ![info exists time($time_element)] } {
            ad_complain [_ acs-tcl.lt_Invalid_time_time_ele]
            return 0
        }
    }

    # check if all elements are blank
    if { "$time(time)$time(ampm)" eq "" } {
        return 1
    }

    set time_element_values [split $time(time) ":"]
    if { [llength $time_element_values] != 3 } {
        ad_complain [_ acs-tcl.lt_Invalid_time_timetime]
        return 0
    }

    set time_element_names [list hours minutes seconds]

    for { set i 0 } { $i < 3 } { incr i } {
        array set time [list [lindex $time_element_names $i] [lindex $time_element_values $i]]
    }

    if {
        "" eq $time(hours)
        || "" eq $time(minutes)
        || "" eq $time(seconds)
        || (![string equal -nocase "pm" $time(ampm)] && ![string equal -nocase "am" $time(ampm)])
        || $time(hours) < 1 || $time(hours) > 12
        || $time(minutes) < 0 || $time(minutes) > 59
        || $time(seconds) < 0 || $time(seconds) > 59
    } {
        ad_complain [_ acs-tcl.lt_Invalid_time_timetime_1]
        return 0
    }

    return 1
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: