From bcc57555b49c86b9c613339627c1eef150979d92 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 13 Feb 2006 04:01:36 +0000 Subject: [PATCH] Removed monthname() and replaced with proper strftime() calls. All date/time output should be fully localized now. --- webcit/calendar.c | 18 +++++++++++------- webcit/calendar_tools.c | 8 +++++++- webcit/calendar_view.c | 22 +++++++++++++++------- webcit/fmt_date.c | 29 ----------------------------- webcit/webcit.h | 1 - 5 files changed, 33 insertions(+), 45 deletions(-) diff --git a/webcit/calendar.c b/webcit/calendar.c index 09735ea79..5353dfa67 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -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(""); wprintf(_("Date:")); - wprintf("" - "%s %d, %d", - monthname(t.month - 1), - t.day, t.year - ); + wprintf("%s", 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("How would you like to respond to this invitation?" - "" + wprintf("%s" + "" "%s" " | " "%s" " | " "%s" "\n", + _("How would you like to respond to this invitation?"), msgnum, cal_partnum, _("Accept"), msgnum, cal_partnum, _("Tentative"), msgnum, cal_partnum, _("Decline") diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index 58e62146f..d62cb8296 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -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("\n"); diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index a82e731b9..edb16d3b3 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -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(""); /** Today's date */ - wprintf(""); - wprintf("%s
" - "%d
" - "%d
", - monthname(month-1), - day, year); - wprintf(""); + 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, + "" + "%B
" + "%d
" + "%Y
" + "", + &d_tm + ); + wprintf("%s", d_str); /** Right arrow */ wprintf(""); diff --git a/webcit/fmt_date.c b/webcit/fmt_date.c index b5681e8ee..a8c16b12a 100644 --- a/webcit/fmt_date.c +++ b/webcit/fmt_date.c @@ -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 diff --git a/webcit/webcit.h b/webcit/webcit.h index 5d89ebebc..da0959ff2 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -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); -- 2.30.2