Removed monthname() and replaced with proper strftime() calls.
authorArt Cancro <ajc@citadel.org>
Mon, 13 Feb 2006 04:01:36 +0000 (04:01 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 13 Feb 2006 04:01:36 +0000 (04:01 +0000)
All date/time output should be fully localized now.

webcit/calendar.c
webcit/calendar_tools.c
webcit/calendar_view.c
webcit/fmt_date.c
webcit/webcit.h

index 09735ea79b0148441c1baf10c83cef89add1b92e..5353dfa67d8f11f7cc9502ff53b0239de196cdb5 100644 (file)
@@ -163,13 +163,16 @@ void cal_process_object(icalcomponent *cal,
                        t = icalproperty_get_dtstart(p);
 
                        if (t.is_date) {
+                               struct tm d_tm;
+                               char d_str[32];
+                               memset(&d_tm, 0, sizeof d_tm);
+                               d_tm.tm_year = t.year - 1900;
+                               d_tm.tm_mon = t.month - 1;
+                               d_tm.tm_mday = t.day;
+                               wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
                                wprintf("<TR><TD><B>");
                                wprintf(_("Date:"));
-                               wprintf("</B></TD><TD>"
-                                       "%s %d, %d</TD></TR>",
-                                       monthname(t.month - 1),
-                                       t.day, t.year
-                               );
+                               wprintf("</B></TD><TD>%s</TD></TR>", d_str);
                        }
                        else {
                                tt = icaltime_as_timet(t);
@@ -264,14 +267,15 @@ void cal_process_object(icalcomponent *cal,
                lprintf(9, "...done.\n");
 
                /** Display the Accept/Decline buttons */
-               wprintf("<TR><TD>How would you like to respond to this invitation?</td>"
-                       "<td><FONT SIZE=+1>"
+               wprintf("<tr><td>%s</td>"
+                       "<td><font size=+1>"
                        "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Accept\">%s</a>"
                        " | "
                        "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Tentative\">%s</a>"
                        " | "
                        "<a href=\"respond_to_request?msgnum=%ld&cal_partnum=%s&sc=Decline\">%s</a>"
                        "</FONT></TD></TR>\n",
+                       _("How would you like to respond to this invitation?"),
                        msgnum, cal_partnum, _("Accept"),
                        msgnum, cal_partnum, _("Tentative"),
                        msgnum, cal_partnum, _("Decline")
index 58e62146f4515055f2e0c60b71107f048be19d06..d62cb8296907e4f39606297176ea92b3350e4675 100644 (file)
@@ -49,6 +49,9 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        struct tm tm;
        const int span = 10;
        int all_day_event = 0;
+       time_t monthselect_time;
+       struct tm monthselect_tm;
+       char monthselect_str[32];
        char calhourformat[16];
 
        get_preference("calhourformat", calhourformat, sizeof calhourformat);
@@ -70,10 +73,13 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        wprintf(_("Month: "));
        wprintf("<SELECT NAME=\"%s_month\" SIZE=\"1\">\n", prefix);
        for (i=0; i<=11; ++i) {
+               monthselect_time = 1137997451 + (i * 2592000);
+               localtime_r(&monthselect_time, &monthselect_tm);
+               wc_strftime(monthselect_str, sizeof monthselect_str, "%B", &monthselect_tm);
                wprintf("<OPTION %s VALUE=\"%d\">%s</OPTION>\n",
                        ((tm.tm_mon == i) ? "SELECTED" : ""),
                        i+1,
-                       monthname(i)
+                       monthselect_str
                );
        }
        wprintf("</SELECT>\n");
index a82e731b90c113f2843ec47faa2dcef273fea7ee..edb16d3b3ed766cff7b3b0495c02ec3daa6d3733 100644 (file)
@@ -578,6 +578,8 @@ void calendar_day_view(int year, int month, int day) {
        int daystart = 8;
        int dayend = 17;
        char daystart_str[16], dayend_str[16];
+       struct tm d_tm;
+       char d_str[128];
 
        get_preference("calhourformat", calhourformat, sizeof calhourformat);
        get_preference("daystart", daystart_str, sizeof daystart_str);
@@ -683,13 +685,19 @@ void calendar_day_view(int year, int month, int day) {
        wprintf("</TD>");
 
        /** Today's date */
-       wprintf("<TD ALIGN=CENTER>");
-       wprintf("<FONT SIZE=+2>%s</FONT><br />"
-               "<FONT SIZE=+3>%d</FONT><br />"
-               "<FONT SIZE=+2>%d</FONT><br />",
-               monthname(month-1),
-               day, year);
-       wprintf("</TD>");
+       memset(&d_tm, 0, sizeof d_tm);
+       d_tm.tm_year = year - 1900;
+       d_tm.tm_mon = month - 1;
+       d_tm.tm_mday = day;
+       wc_strftime(d_str, sizeof d_str,
+               "<td align=center>"
+               "<font size=+2>%B</font><br />"
+               "<font size=+3>%d</font><br />"
+               "<font size=+2>%Y</font><br />"
+               "</td>",
+               &d_tm
+       );
+       wprintf("%s", d_str);
 
        /** Right arrow */
        wprintf("<TD ALIGN=CENTER>");
index b5681e8ee9072bd09eb0c095719657efec186fa6..a8c16b12a5136dcd64ca8f32433730b7e1cb6b17 100644 (file)
@@ -84,35 +84,6 @@ void fmt_date(char *buf, time_t thetime, int brief)
        }
 }
 
-/**
- * \brief      Convenience function to return a month name
- *
- * \param      m               Numeric month
- */
-char *monthname(int m)
-{
-       static char months[12][32];
-       static int initialized = 0;
-
-       time_t tt;
-       struct tm tm;
-       int i;
-
-       if (!initialized) {
-               for (i=0; i<12; ++i) {
-                       tt = 1137997451 + (i * 2592000);
-                       localtime_r(&tt, &tm);
-                       wc_strftime(months[i], 32, "%B", &tm);
-                       lprintf(9, "%s\n", months[i]);
-               }
-       }
-       initialized = 1;
-
-       return months[m];
-               
-}
-
-
 
 /**
  * \brief Format TIME ONLY for output 
index 5d89ebebc78b6f67d92da9749caede0eb2c67b96..da0959ff2b88a4144b337717a6da8c4fd00b9534 100644 (file)
@@ -553,7 +553,6 @@ void session_loop(struct httprequest *);
 size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm);
 void fmt_date(char *buf, time_t thetime, int brief);
 void fmt_time(char *buf, time_t thetime);
-char *monthname(int m);
 void httpdate(char *buf, time_t thetime);
 time_t httpdate_to_timestamp(char *buf);
 void end_webcit_session(void);