+/**
+ * \brief view one month. brief view
+ * \param year the year
+ * \param month the month
+ * \param day the actual day we want to see
+ */
+void calendar_brief_month_view(int year, int month, int day) {
+ struct tm starting_tm;
+ struct tm tm;
+ time_t thetime;
+ int i;
+ time_t previous_month;
+ time_t next_month;
+ char month_label[32];
+
+ /** Determine what day to start.
+ * First, back up to the 1st of the month...
+ */
+ memset(&starting_tm, 0, sizeof(struct tm));
+ starting_tm.tm_year = year - 1900;
+ starting_tm.tm_mon = month - 1;
+ starting_tm.tm_mday = day;
+ thetime = mktime(&starting_tm);
+
+ memcpy(&tm, &starting_tm, sizeof(struct tm));
+ while (tm.tm_mday != 1) {
+ thetime = thetime - (time_t)86400; /* go back 24 hours */
+ localtime_r(&thetime, &tm);
+ }
+
+ /** Determine previous and next months ... for links */
+ previous_month = thetime - (time_t)864000L; /* back 10 days */
+ next_month = thetime + (time_t)(31L * 86400L); /* ahead 31 days */
+
+ /** Now back up until we're on a Sunday */
+ localtime_r(&thetime, &tm);
+ while (tm.tm_wday != 0) {
+ thetime = thetime - (time_t)86400; /* go back 24 hours */
+ localtime_r(&thetime, &tm);
+ }
+
+ /** Outer table (to get the background color) */
+ wprintf("<div class=\"fix_scrollbar_bug\">"
+ "<table width=100%% border=0 cellpadding=0 cellspacing=0 "
+ "bgcolor=#204B78><TR><TD>\n");
+
+ wprintf("<table width=100%% border=0 cellpadding=0 cellspacing=0><tr>\n");
+
+ wprintf("<td align=center>");
+
+ localtime_r(&previous_month, &tm);
+ wprintf("<a href=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
+ (int)(tm.tm_year)+1900, tm.tm_mon + 1);
+ wprintf("<img align=middle src=\"static/prevdate_32x.gif\" border=0></A>\n");
+
+ wc_strftime(month_label, sizeof month_label, "%B", &tm);
+ wprintf(" "
+ "<font size=+1 color=\"#FFFFFF\">"
+ "%s %d"
+ "</font>"
+ " ", month_label, year);
+
+ localtime_r(&next_month, &tm);
+ wprintf("<a href=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
+ (int)(tm.tm_year)+1900, tm.tm_mon + 1);
+ wprintf("<img align=middle src=\"static/nextdate_32x.gif\" border=0></A>\n");
+
+ wprintf("</td></tr></table>\n");
+
+ /** Inner table (the real one) */
+ wprintf("<table width=100%% border=0 cellpadding=1 cellspacing=1 "
+ "bgcolor=#EEEECC><TR>");
+ wprintf("</tr>\n");
+ wprintf("<tr><td colspan=\"100%\">\n");
+
+ /** Now do 35 days */
+ for (i = 0; i < 35; ++i) {
+ char weeknumber[255];
+ char weekday_name[32];
+ char *daycolor;
+ localtime_r(&thetime, &tm);
+
+
+ /** Before displaying Sunday, start a new CELL */
+ if ((i % 7) == 0) {
+ wc_strftime(&weeknumber[0], sizeof(weeknumber), "%U", &tm);
+ wprintf("<table border='0' bgcolor=\"#EEEECC\" width='100%'> <tr><th colspan='4'>%s %s</th></tr>"
+ " <tr><td>%s</td><td width='70%'>%s</td><td>%s</td><td>%s</td></tr>\n",
+ _("Week"),
+ weeknumber,
+ _("Hours"),
+ _("Subject"),
+ _("Start"),
+ _("End")
+ );
+ }
+
+ daycolor=((tm.tm_mon != month-1) ? "DDDDDD" :
+ ((tm.tm_wday==0 || tm.tm_wday==6) ? "EEEECC" :
+ "FFFFFF"));
+
+ /** Day Header */
+ wc_strftime(weekday_name, sizeof weekday_name, "%A", &tm);
+ wprintf("<tr><td bgcolor='%s' colspan='1' align='left'> %s,%i."
+ "</td><td bgcolor='%s' colspan='3'><hr></td></tr>\n",
+ daycolor,
+ weekday_name,tm.tm_mday,
+ daycolor);
+
+ /** put the data of one day here, stupid */
+ calendar_month_view_brief_events(thetime, daycolor);
+
+
+ /** After displaying Saturday, end the row */
+ if ((i % 7) == 6) {
+ wprintf("</td></tr></table>\n");
+ }
+
+ thetime += (time_t)86400; /** ahead 24 hours */
+ }
+
+ wprintf("</table>" /** end of inner table */
+ "</td></tr></table>" /** end of outer table */
+ "</div>\n");
+}