_acs-templating__template_date_api (private)
_acs-templating__template_date_api
Defined in packages/acs-templating/tcl/test/date-procs.tcl
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set _aa_export {} set body_count 1 foreach testcase_body {{ aa_section "From SQL - Valid input" set test_data { 2023-02-20 {2023 2 20 0 0 0 {DD MONTH YYYY}} {2023-02-20 22:10} {2023 2 20 0 0 0 {DD MONTH YYYY}} {2023-02-20 22:10:100} {2023 2 20 22 10 10 {DD MONTH YYYY}} {2023-02-20 22:10:900} {2023 2 20 22 10 9 {DD MONTH YYYY}} {2023-02-23 99-00-00} {2023 2 23 0 0 0 {DD MONTH YYYY}} 2023-02-99 {2023 2 9 0 0 0 {DD MONTH YYYY}} {0000-00-00 00:00:00} {0000 0 0 0 0 0 {DD MONTH YYYY}} "" {{} {} {} {} {} {} {DD MONTH YYYY}} } foreach {input expected} $test_data { aa_equals "template::data::from_sql::date on '$input' returns expected" [template::data::from_sql::date $input] $expected aa_equals "template::data::from_sql::time_of_day on '$input' returns expected" [template::data::from_sql::time_of_day $input] $expected aa_equals "template::data::from_sql::timestamp on '$input' returns expected" [template::data::from_sql::timestamp $input] $expected } aa_section "From SQL - Invalid input" set test_data { 2023-50-00 a 111 {1-1-1 a b c} 1-1-1 } foreach input $test_data { aa_true "template::data::from_sql::date on '$input' returns error" [catch { template::data::from_sql::date $input }] aa_true "template::data::from_sql::time_of_day on '$input' returns error" [catch { template::data::from_sql::time_of_day $input }] aa_true "template::data::from_sql::timestamp on '$input' returns error" [catch { template::data::from_sql::timestamp $input }] } aa_section "To SQL - Valid input" set test_data { {2023 2 20 0 0 0 {DD MONTH YYYY}} "to_timestamp('2023 02 20 00 00 00', 'YYYY MM DD HH24 MI SS')" {2023 2 20 22 10 100 {DD MONTH YYYY}} "to_timestamp('2023 02 20 22 10 100', 'YYYY MM DD HH24 MI SS')" {2023 2 20 22 10 900 {DD MONTH YYYY}} "to_timestamp('2023 02 20 22 10 900', 'YYYY MM DD HH24 MI SS')" {2023 2 23 99 0 0 {DD MONTH YYYY}} "to_timestamp('2023 02 23 99 00 00', 'YYYY MM DD HH24 MI SS')" {2023 2 99 0 0 0 {DD MONTH YYYY}} "to_timestamp('2023 02 99 00 00 00', 'YYYY MM DD HH24 MI SS')" {0 0 0 0 0 0 {DD MONTH YYYY}} "to_timestamp('0000 00 00 00 00 00', 'YYYY MM DD HH24 MI SS')" 2023-50-00 "to_date('2023-50-00', 'YYYY')" a "to_date('000a', 'YYYY')" 111 "to_date('0111', 'YYYY')" {1-1-1 a b c} "to_timestamp('1-1-1 0a 0b 0c', 'YYYY MM DD HH24')" 1-1-1 "to_date('1-1-1', 'YYYY')" "" NULL } foreach {input expected} $test_data { aa_equals "template::data::from_sql::date on '$input' returns expected" [template::data::to_sql::date $input] $expected aa_equals "template::data::from_sql::time_of_day on '$input' returns expected" [template::data::to_sql::time_of_day $input] $expected aa_equals "template::data::from_sql::timestamp on '$input' returns expected" [template::data::to_sql::timestamp $input] $expected } set test_data { {2023 2 20 0 0 0 {DD MONTH YYYY}} 2023-50-00 a 111 {1-1-1 a b c} 1-1-1 "" } set vars {year month day hours minutes seconds format} foreach input $test_data { template::util::date::unpack $input set i 0 foreach v $vars { aa_equals "template::util::date::unpack on '$input' for '$v' returns expected" [set ${v}] [lindex $input $i] incr i } } }} { aa_log "Running testcase body $body_count" set ::__aa_test_indent [info level] set catch_val [catch $testcase_body msg] if {$catch_val != 0 && $catch_val != 2} { aa_log_result "fail" "template_date_api (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle