commit 8dd5101

grunfink  ·  2026-02-02 17:10:01 +0000 UTC
parent 7d24c6f
Use the translated month names in date labels.
2 files changed,  +15, -1
M data.c
M html.c
M data.c
+1, -0
1@@ -41,6 +41,7 @@ int srv_open(const char *basedir, int auto_upgrade)
2     FILE *f;
3     xs_str *error = NULL;
4 
5+    /* MUST be three letters */
6     months[0] = LL("Jan");
7     months[1] = LL("Feb");
8     months[2] = LL("Mar");
M html.c
+14, -1
 1@@ -225,7 +225,20 @@ xs_str *html_date_label(snac *user, const char *date)
 2             return xs_str_utctime(t, "%Y-%m-%d %H:%M");
 3         }
 4 
 5-        return xs_str_utctime(t, "%b%d %H:%M");
 6+        xs_str *date = xs_str_utctime(t, "%b%d %H:%M");
 7+
 8+        struct tm tm;
 9+        localtime_r(&t, &tm);
10+
11+        if (tm.tm_mon >= 0 && tm.tm_mon <= 11) {
12+            /* copy the 3letter translated month name */
13+            const char *m = L(months[tm.tm_mon]);
14+
15+            if (xs_is_string(m) && strlen(m) >= 3)
16+                memcpy(date, m, 3);
17+        }
18+
19+        return date;
20     }
21 
22     return xs_crop_i(xs_dup(date), 0, 10);