time_t monthselect_time;
struct tm monthselect_tm;
char monthselect_str[32];
- char calhourformat[16];
-
- get_preference("calhourformat", calhourformat, sizeof calhourformat);
+ int time_format;
+
+ time_format = get_time_format_cached ();
now = time(NULL);
localtime_r(&now, &tm_now);
wprintf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
for (i=0; i<=23; ++i) {
- if (!strcasecmp(calhourformat, "24")) {
+ if (time_format == WC_TIMEFORMAT_24) {
wprintf("<OPTION %s VALUE=\"%d\">%d</OPTION>\n",
((tm.tm_hour == i) ? "SELECTED" : ""),
i, i
struct icaltimetype t;
int month, day, year;
int all_day_event = 0;
- char calhourformat[16];
char *timeformat;
+ int time_format;
+
+ time_format = get_time_format_cached ();
- get_preference("calhourformat", calhourformat, sizeof calhourformat);
- if (!strcasecmp(calhourformat, "24")) timeformat="%k:%M";
+ if (time_format == WC_TIMEFORMAT_24) timeformat="%k:%M";
else timeformat="%I:%M %p";
localtime_r(&thetime, &today_tm);
void calendar_day_view(int year, int month, int day) {
int hour;
struct icaltimetype today, yesterday, tomorrow;
- char calhourformat[16];
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);
+ int time_format;
+
+ time_format = get_time_format_cached ();
get_preference("daystart", daystart_str, sizeof daystart_str);
if (!IsEmptyStr(daystart_str)) daystart = atoi(daystart_str);
get_preference("dayend", dayend_str, sizeof dayend_str);
year, month, day, hour
);
- if (!strcasecmp(calhourformat, "24")) {
+ if (time_format == WC_TIMEFORMAT_24) {
wprintf("%2d:00</a> ", hour);
}
else {
fi
]
)
-echo "$CFLAGS $LDFLAGS"
if test "$prefix" = NONE; then
LOCALEDIR=$ac_default_prefix
struct tm today_tm;
time_t today_timet;
int hour;
- char calhourformat[16];
-
- get_preference("calhourformat", calhourformat, sizeof calhourformat);
-
+ int time_format;
+
+ time_format = get_time_format_cached ();
+/// TODO: what about the time format?
today_timet = time(NULL);
localtime_r(&today_timet, &today_tm);
}
+/**
+ * \brief learn the users timeformat preference.
+ */
+int get_time_format_cached (void)
+{
+ char calhourformat[16];
+ int *time_format_cache;
+ time_format_cache = &(WC->time_format_cache);
+ if (*time_format_cache == WC_TIMEFORMAT_NONE)
+ {
+ get_preference("calhourformat", calhourformat, sizeof calhourformat);
+ if (!strcasecmp(calhourformat, "24"))
+ *time_format_cache = WC_TIMEFORMAT_24;
+ else
+ *time_format_cache = WC_TIMEFORMAT_AMPM;
+ }
+ return *time_format_cache;
+}
+
/**
* \brief Format TIME ONLY for output
* \param buf the output buffer
{
struct tm *tm;
int hour;
- char calhourformat[16];
-
- get_preference("calhourformat", calhourformat, sizeof calhourformat);
-
+ int time_format;
+
+ time_format = get_time_format_cached ();
buf[0] = 0;
tm = localtime(&thetime);
hour = tm->tm_hour;
else if (hour > 12)
hour = hour - 12;
- if (!strcasecmp(calhourformat, "24")) {
+ if (time_format == WC_TIMEFORMAT_24) {
sprintf(buf, "%2d:%02d",
tm->tm_hour, tm->tm_min
);
output_headers(1, 1, 1, 0, 0, 0);
char ebuf[300];
char buf[256];
- char calhourformat[16];
int i;
+ int time_format;
+
+ time_format = get_time_format_cached ();
wprintf("<div class=\"box\">\n");
wprintf("<div class=\"boxlabel\">");
/**
* Calendar hour format
*/
- get_preference("calhourformat", calhourformat, sizeof calhourformat);
- if (calhourformat[0] == 0) strcpy(calhourformat, "12");
+
wprintf("<tr class=\"odd\"><td>");
wprintf(_("Calendar hour format"));
wprintf("</td><td>");
wprintf("<input type=\"radio\" name=\"calhourformat\" VALUE=\"12\"");
- if (!strcasecmp(calhourformat, "12")) wprintf(" checked");
+ if (time_format == WC_TIMEFORMAT_AMPM)
+ wprintf(" checked");
wprintf(">");
wprintf(_("12 hour (am/pm)"));
wprintf("</input> ");
wprintf("<input type=\"radio\" name=\"calhourformat\" VALUE=\"24\"");
- if (!strcasecmp(calhourformat, "24")) wprintf(" checked");
+ if (time_format == WC_TIMEFORMAT_24)
+ wprintf(" checked");
wprintf(">");
wprintf(_("24 hour"));
wprintf("</input>\n");
wprintf("<select name=\"daystart\" size=\"1\">\n");
for (i=0; i<=23; ++i) {
- if (!strcasecmp(calhourformat, "24")) {
+ if (time_format == WC_TIMEFORMAT_24) {
wprintf("<option %s value=\"%d\">%d:00</option>\n",
((atoi(buf) == i) ? "selected" : ""),
i, i
wprintf("<select name=\"dayend\" size=\"1\">\n");
for (i=0; i<=23; ++i) {
- if (!strcasecmp(calhourformat, "24")) {
+ if (time_format == WC_TIMEFORMAT_24) {
wprintf("<option %s value=\"%d\">%d:00</option>\n",
((atoi(buf) == i) ? "selected" : ""),
i, i
*/
void set_preferences(void)
{
+ char *fmt;
char ebuf[300];
+ int *time_format_cache;
+
+ time_format_cache = &(WC->time_format_cache);
if (IsEmptyStr(bstr("change_button"))) {
safestrncpy(WC->ImportantMessage,
* we don't send the prefs file to the server repeatedly
*/
set_preference("roomlistview", bstr("roomlistview"), 0);
- set_preference("calhourformat", bstr("calhourformat"), 0);
+ fmt = bstr("calhourformat");
+ set_preference("calhourformat", fmt, 0);
+ if (!strcasecmp(fmt, "24"))
+ *time_format_cache = WC_TIMEFORMAT_24;
+ else
+ *time_format_cache = WC_TIMEFORMAT_AMPM;
+
set_preference("use_sig", bstr("use_sig"), 0);
set_preference("daystart", bstr("daystart"), 0);
set_preference("dayend", bstr("dayend"), 0);
int selected_language; /**< Language selected by user */
time_t last_pager_check; /**< last time we polled for instant msgs */
int nonce; /**< session nonce (to prevent session riding) */
+ int time_format_cache; /**< which timeformat does our user like? */
};
/** values for WC->current_iconbar */
void str_wiki_index(char *s);
void display_wiki_page(void);
char *bmstrcasestr(char *text, char *pattern);
+int get_time_format_cached (void);
#ifdef HAVE_ICONV
iconv_t ctdl_iconv_open(const char *tocode, const char *fromcode);
*/
#define WC_EXIT_BIND 101 /* Can't bind to the port */
#define WC_EXIT_SSL 102 /* Can't initialize SSL */
+
+
+#define WC_TIMEFORMAT_NONE 0
+#define WC_TIMEFORMAT_AMPM 1
+#define WC_TIMEFORMAT_24 2
+
+