dt_get_info (public)

 dt_get_info [ -element element ] [ -dict ] [ the_date ]

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

Calculates various dates required by the dt_widget_month procedure. Defines, in the caller's environment, a whole set of variables needed for calendar display. Returns the following (example for the_date = 2000-12-08): julian_date_today 2451887 month December year 2000 first_julian_date 2451875 first_julian_date_of_month 2451880 num_days_in_month 31 last_julian_date_in_month 2451910 last_julian_date 2451916 first_day 26 first_day_of_month 6 last_day 31 next_month 2001-01-01 prev_month 2000-11-01 beginning_of_year 2000-01-01 days_in_last_month 30 next_month_name January prev_month_name November

Switches:
-element
(optional)
when set, the proc will return this date property only and will not set any variable in the caller scope. Trying to fetch a non-existing property will throw an error.
-dict
(boolean) (optional)
when set, the proc will return all properties as a dict and will not set any variable in the caller scope.
Parameters:
the_date (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_dt_get_info dt_get_info (test acs-datetime) dt_get_info dt_get_info test_dt_get_info->dt_get_info dt_ansi_to_julian dt_ansi_to_julian (public) dt_get_info->dt_ansi_to_julian dt_ansi_to_list dt_ansi_to_list (public) dt_get_info->dt_ansi_to_list dt_first_day_of_month dt_first_day_of_month (public) dt_get_info->dt_first_day_of_month dt_next_month dt_next_month (public) dt_get_info->dt_next_month dt_next_month_name dt_next_month_name (public) dt_get_info->dt_next_month_name dt_widget_calendar_navigation dt_widget_calendar_navigation (public, deprecated) dt_widget_calendar_navigation->dt_get_info dt_widget_calendar_year dt_widget_calendar_year (public, deprecated) dt_widget_calendar_year->dt_get_info dt_widget_month dt_widget_month (public, deprecated) dt_widget_month->dt_get_info dt_widget_month_centered dt_widget_month_centered (public, deprecated) dt_widget_month_centered->dt_get_info dt_widget_year dt_widget_year (public, deprecated) dt_widget_year->dt_get_info

Testcases:
dt_get_info
Source code:
    # If no date was passed in, let's set it to today

    if {$the_date eq ""} {
        set the_date [dt_sysdate]
    }

    # get year, month, day
    lassign [dt_ansi_to_list $the_date] year month day

    # We put all the data into a list and set it in the caller scope
    # later.
    set dt_info [list]

    lappend dt_info julian_date_today  [dt_ansi_to_julian $year $month $day]

    lappend dt_info month  [lc_time_fmt $the_date "%B"]

    lappend dt_info year  [clock format [clock scan $the_date] -format %Y]

    set first_julian_date_of_month [dt_ansi_to_julian $year $month 1]
    lappend dt_info first_julian_date_of_month  $first_julian_date_of_month

    set num_days_in_month [dt_num_days_in_month $year $month]
    lappend dt_info num_days_in_month  $num_days_in_month

    set first_day_of_month [dt_first_day_of_month $year $month]
    lappend dt_info first_day_of_month  $first_day_of_month

    lappend dt_info last_day  [dt_num_days_in_month $year $month]

    lappend dt_info next_month  [dt_next_month $year $month]

    lappend dt_info prev_month  [dt_prev_month $year $month]

    lappend dt_info beginning_of_year  $year-01-01

    set days_in_last_month [dt_num_days_in_month $year [expr {$month - 1}]]
    lappend dt_info days_in_last_month  $days_in_last_month

    lappend dt_info next_month_name  [dt_next_month_name $year $month]

    lappend dt_info prev_month_name  [dt_prev_month_name $year $month]

    lappend dt_info first_julian_date  [expr {$first_julian_date_of_month + 1 - $first_day_of_month}]

    lappend dt_info first_day  [expr {$days_in_last_month + 2 - $first_day_of_month}]

    lappend dt_info last_julian_date_in_month  [expr {$first_julian_date_of_month + $num_days_in_month - 1}]

    set days_in_next_month  [expr {(7-(($num_days_in_month + $first_day_of_month - 1) % 7)) % 7}]

    lappend dt_info last_julian_date  [expr {$first_julian_date_of_month + $num_days_in_month - 1 + $days_in_next_month}]

    if {[info exists element]} {
        #
        # Return the single property.
        #
        return [dict get $dt_info_element]
    } elseif {$dict_p} {
        #
        # Return the entire dict.
        #
        return $dt_info
    } else {
        #
        # Set the variables in the caller's environment.
        #
        foreach {key value} $dt_info {
            upvar $key var
            set var $value
        }
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: