Fixed locale defaulting to English
authorVincent Loupmon <vincentloupmon@gmail.com>
Thu, 10 Mar 2016 15:50:32 +0000 (16:50 +0100)
committerVincent Loupmon <vincentloupmon@gmail.com>
Thu, 10 Mar 2016 15:50:32 +0000 (16:50 +0100)
Changed get_datetime() a bit so it respects the user-configured locale (to use time formats with strings for days, months etc.)

Same commit as last time, except it merges.

slstatus.c

index 23ed940a55cae6efc09ab4581c666b100dd76b3d..fe27be493413afc394fda5b88ac4912e56eb797f 100644 (file)
@@ -3,6 +3,7 @@
 /* global libraries */
 #include <alsa/asoundlib.h>
 #include <fcntl.h>
+#include <locale.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -191,11 +192,14 @@ get_datetime()
 
     /* get time in format */
     time(&tm);
+    setlocale(LC_TIME, "");
     if(!strftime(buf, bufsize, timeformat, localtime(&tm))) {
+        setlocale(LC_TIME, "C");
         fprintf(stderr, "Strftime failed.\n");
         return smprintf("n/a");
     }
 
+    setlocale(LC_TIME, "C");
     /* return time */
     return smprintf("%s", buf);
 }