template::util::date::add_time (public)

 template::util::date::add_time -time_array_name time_array_name \
    -date_array_name date_array_name

Defined in packages/acs-templating/tcl/date-procs.tcl

Set the time and date and new format properties into one date object (list) which is returned. Not sure this proc should live here...

Switches:
-time_array_name
(required)
-date_array_name
(required)
Author:
Walter McGinnis <wtem@olywa.net>
Created:
2002-01-04

Partial Call Graph (max 5 caller/called nodes):
%3 template::util::date::create template::util::date::create (public) template::util::date::set_property template::util::date::set_property (public) template::util::date::add_time template::util::date::add_time template::util::date::add_time->template::util::date::create template::util::date::add_time->template::util::date::set_property

Testcases:
No testcase defined.
Source code:
    # grab the form arrays
    upvar 1 $time_array_name time_in $date_array_name date_in

    # combine the two formats...
    # date first
    set new_format "$date_in(format) $time_in(format)"

    # create an empty date object with the new format
    set the_date [template::util::date::create  "" "" "" "" "" "" ""]

    set the_date [template::util::date::set_property format $the_date $new_format]

    set have_values 0

    # the following two foreachs might be cleaner if combined into one
    # but two is pretty simple and there are larger battles out there to fight

    # add time properties
    foreach field [array names time_in] {
        # skip format
        if {$field ne "format" } {
            # Coerce values to nonnegative integers
            if { $field ne "ampm" } {
                if { ![regexp {[0-9]+} $time_in($field) value] } {
                    set value {}
                }
            }
            # If the value is not null, set it
            if { $value ne {} } {
                set the_date [template::util::date::set_property $field $the_date $value]
                if { $field ne "ampm" } {
                    set have_values 1
                }
            }
        }
    }

    # add date properties
    foreach field [array names date_in] {
        # skip format
        if {$field ne "format" } {
            # Coerce values to nonnegative integers
            if { ![regexp {[0-9]+} $date_in($field) value] } {
                set value {}
            }
            # If the value is not null, set it
            if { $value ne {} } {
                set the_date [template::util::date::set_property $field $the_date $value]
                set have_values 1
            }
        }
    }

    if { $have_values } {
        return [list $the_date]
    } else {
        return {}
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: