Index: openacs-4/packages/acs-templating/tcl/test/date-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/test/date-procs.tcl,v diff -u -r1.5.2.4 -r1.5.2.5 --- openacs-4/packages/acs-templating/tcl/test/date-procs.tcl 28 Jun 2021 11:11:04 -0000 1.5.2.4 +++ openacs-4/packages/acs-templating/tcl/test/date-procs.tcl 20 Feb 2023 16:17:11 -0000 1.5.2.5 @@ -83,6 +83,52 @@ } } +aa_register_case \ + -cats { + api + production_safe + } -procs { + template::data::from_sql::date + template::util::date::acquire + template::util::date::create + template::util::date::set_property + } template_date_api { + Test api manipulating the template date format. + } { + aa_section "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}} + } + + foreach {input expected} $test_data { + aa_equals "template::data::from_sql::date on '$input' returns expected" \ + [template::data::from_sql::date $input] $expected + } + + + aa_section "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 + }] + } + } + # Local variables: # mode: tcl # tcl-indent-level: 4