diff options
Diffstat (limited to 'articles/2025/Slstatus-date-with-alternative-locale.html')
| -rwxr-xr-x | articles/2025/Slstatus-date-with-alternative-locale.html | 59 |
1 files changed, 59 insertions, 0 deletions
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 @@ +<!doctype html> +<html lang="EN"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="/style.css"> + <title>Slstatus date with alternative locale</title> + </head> + <body> + <header> + <h1>Bloggings</h1> + <a href="/index.php">Back</a> + + </header> + +<main> +<article> +<h2>Slstatus date with alternative locale</h2> +<h3>2025-04-26</h3> +<h4>Modifying slstatus to display French date</h4> +<p>My default locale is en-US, but I wanted to display weekdays in French in the slstatus bar.</p> +<p>The solution is to add setlocale to the function in <br><b>slstatus/components/datetime.c</b></p> +<p><img src="/images/blog/slstatus-french.png"></p> +<pre> +/* See LICENSE file for copyright and license details. */ +#include <stdio.h> +#include <time.h> +<b>#include <locale.h></b> + +#include "../slstatus.h" +#include "../util.h" + + +const char * +datetime(const char *fmt) +{ + <b>setlocale(LC_ALL,"fr_FR.utf8");</b> + 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; +} +</pre> +</article> +</main> +<footer> + +<p> </p> + +<p>ยง</p> + </footer> +</body> +</html> |
