}
+/*
+ * Try to guess whether the user will prefer 12 hour or 24 hour time based on the locale.
+ */
+long guess_calhourformat(void) {
+ char buf[32];
+ struct tm tm;
+ memset(&tm, 0, sizeof tm);
+ wc_strftime(buf, 32, "%X", &tm);
+ if (buf[strlen(buf)-1] == 'M') {
+ return 12;
+ }
+ return 24;
+}
+
+
/*
* learn the users timeformat preference.
*/
time_format_cache = &(WC->time_format_cache);
if (*time_format_cache == WC_TIMEFORMAT_NONE)
{
- get_pref_long("calhourformat", &calhourformat, 24);
+ get_pref_long("calhourformat", &calhourformat, 99);
+
+ /* If we don't know the user's time format preference yet,
+ * make a guess based on the locale.
+ */
+ if (calhourformat == 99) {
+ calhourformat = guess_calhourformat();
+ }
+
+ /* Now set the preference */
if (calhourformat == 24)
*time_format_cache = WC_TIMEFORMAT_24;
else
void begin_tab(int tabnum, int num_tabs);
void end_tab(int tabnum, int num_tabs);
void str_wiki_index(char *s);
+long guess_calhourformat(void);
int get_time_format_cached (void);
int xtoi(const char *in, size_t len);
const char *get_selected_language(void);