# # # get_calendar_info() # # # Creates and returns a calendar_info node which is used to create the javascript and html calendar. # The calendar node includes all dates, it means it includes any missing log days. # Misssing log days are indicated in the subnode missing_log_data_days # # Note, the forward slash in a date is a problem in the URL! # So we use dates without a forward slash, i.e.: # 2006, Jan2006, 1Jan2006, 18Jan2006, 18Jan2006_18:20:18:,last3months, etc. # The alternative is 18_Jan_2006_18_20_18 # subroutine(get_calendar_info( string profile_name, string earliest_log_date, string latest_log_date), ( delete_node("v.calendar_info"); v.calendar_info = ""; node calendar_info = "v.calendar_info"; # get log data calendar delete_node("v.temp_log_data_dates"); v.temp_log_data_dates = ""; query_db_calendar("v.temp_log_data_dates"); node log_data_dates_node = "v.temp_log_data_dates"; debug_message("\n\n" . node_as_string(log_data_dates_node) . "\n"); # node log_data_dates_node = "v.temp_log_data_dates"; int earliest_year = get_year(earliest_log_date); int earliest_month = get_month_as_number(earliest_log_date); int latest_year = get_year(latest_log_date); int latest_month = get_month_as_number(latest_log_date); int start_month; int end_month; node year_node; node month_node; int number_of_days_in_month; string weekday_of_first_of_month; string logged_days_path; node missing_log_data_days_node; bool month_has_log_data; for (int this_year = earliest_year; this_year <= latest_year; this_year++) ( # # add year to calendar info # set_subnode_value(calendar_info, this_year, ""); year_node = calendar_info{this_year}; # # add month(s) to calendar info # start_month = if (this_year == earliest_year) then (earliest_month) else (1); end_month = if (this_year == latest_year) then (latest_month) else (12); for (int this_month = start_month; this_month <= end_month; this_month++) ( set_subnode_value(year_node, this_month, ""); month_node = year_node{this_month}; number_of_days_in_month = get_number_of_days_in_month(this_year, this_month); weekday_of_first_of_month = get_weekday(this_year, this_month, 1); set_subnode_value(month_node, "month", this_month); set_subnode_value(month_node, "days_in_month", number_of_days_in_month); set_subnode_value(month_node, "weekday_of_first_of_month", weekday_of_first_of_month); set_subnode_value(month_node, "missing_log_data_days", ""); missing_log_data_days_node = month_node{"missing_log_data_days"}; # # add missing log data days if any # logged_days_path = log_data_dates_node . "." . this_year . "." . this_month; if (!(?logged_days_path) or (num_subnodes(logged_days_path) != number_of_days_in_month)) then ( for (int this_day = 1; this_day <= number_of_days_in_month; this_day++) ( if (!(?(logged_days_path . "." . this_day))) then ( set_subnode_value(missing_log_data_days_node, this_day, true); ); ); ); # # check if the month has log data # month_has_log_data = if (number_of_days_in_month != num_subnodes(missing_log_data_days_node)) then (true) else (false); # month_has_log_data = false; set_subnode_value(month_node, "month_has_log_data", month_has_log_data); ); ); debug_message("\n\n" . node_as_string(calendar_info) . "\n"); calendar_info; ));