From 420ceb49b53a8fa9d8ba8443e42e50cd7bd7cea9 Mon Sep 17 00:00:00 2001 From: Philip Wittamore Date: Sun, 12 Jul 2026 11:08:50 +0200 Subject: update --- .../Slstatus-date-with-alternative-locale.html | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 articles/2025/Slstatus-date-with-alternative-locale.html (limited to 'articles/2025/Slstatus-date-with-alternative-locale.html') diff --git a/articles/2025/Slstatus-date-with-alternative-locale.html b/articles/2025/Slstatus-date-with-alternative-locale.html new file mode 100755 index 0000000..60d7b44 --- /dev/null +++ b/articles/2025/Slstatus-date-with-alternative-locale.html @@ -0,0 +1,59 @@ + + + + + + + Slstatus date with alternative locale + + +
+

Bloggings

+ Back + +
+ +
+
+

Slstatus date with alternative locale

+

2025-04-26

+

Modifying slstatus to display French date

+

My default locale is en-US, but I wanted to display weekdays in French in the slstatus bar.

+

The solution is to add setlocale to the function in
slstatus/components/datetime.c

+

+
+/* See LICENSE file for copyright and license details. */
+#include <stdio.h>
+#include <time.h>
+#include <locale.h>
+
+#include "../slstatus.h"
+#include "../util.h"
+
+
+const char *
+datetime(const char *fmt)
+{    
+	setlocale(LC_ALL,"fr_FR.utf8");
+	time_t t;
+
+	t = time(NULL);
+
+	if (!strftime(buf, sizeof(buf), fmt, localtime(&t))) {
+		warn("strftime: Result string exceeds buffer size");
+		return NULL;
+	}
+
+	return buf;
+}
+
+
+
+ + + -- cgit v1.3.1