calendar::from_sql_datetime (public, deprecated)

 calendar::from_sql_datetime -sql_date sql_date -format format

Defined in packages/calendar/tcl/calendar-procs.tcl

Deprecated. Invoking this procedure generates a warning.

Converts a date in a specified format into a templating date dict.

Switches:
-sql_date (required)
a date in one of the supported format.
-format (required)
one of the supported format, "YYYY-MM-DD", "HH12:MIam" or "HH24:MI". When unspecified or invalid, we will try to treat the date as an ansi date. DEPRECATED: this api has been superseded by api in acs-templating.
See Also:

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

Testcases:
No testcase defined.
Source code:
ad_log_deprecated proc calendar::from_sql_datetime
    # for now, we recognize only "YYYY-MM-DD" "HH12:MIam" and "HH24:MI".
    set date [template::util::date::create]

    switch -exact -- $format {
        {YYYY-MM-DD} {
            regexp {([0-9]*)-([0-9]*)-([0-9]*)} $sql_date all year month day

            set date [template::util::date::set_property format $date {DD MONTH YYYY}]
            set date [template::util::date::set_property year $date $year]
            set date [template::util::date::set_property month $date $month]
            set date [template::util::date::set_property day $date $day]
        }

        {HH12:MIam} {
            regexp {([0-9]*):([0-9]*) *([aApP][mM])} $sql_date all hours minutes ampm

            set date [template::util::date::set_property format $date {HH12:MI am}]
            set date [template::util::date::set_property hours $date $hours]
            set date [template::util::date::set_property minutes $date $minutes]
            set date [template::util::date::set_property ampm $date [string tolower $ampm]]
        }

        {HH24:MI} {
            regexp {([0-9]*):([0-9]*)} $sql_date all hours minutes

            set date [template::util::date::set_property format $date {HH24:MI}]
            set date [template::util::date::set_property hours $date $hours]
            set date [template::util::date::set_property minutes $date $minutes]
        }

        {HH24} {
            set date [template::util::date::set_property format $date {HH24:MI}]
            set date [template::util::date::set_property hours $date $sql_date]
            set date [template::util::date::set_property minutes $date 0]
        }
        default {
            set date [template::util::date::set_property ansi $date $sql_date]
        }
    }

    return $date
Generic XQL file:
packages/calendar/tcl/calendar-procs.xql

PostgreSQL XQL file:
packages/calendar/tcl/calendar-procs-postgresql.xql

Oracle XQL file:
packages/calendar/tcl/calendar-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: