summaryrefslogtreecommitdiff
path: root/src/print_time.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/print_time.c')
-rw-r--r--src/print_time.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/print_time.c b/src/print_time.c
index 9fa6642..c8da9d6 100644
--- a/src/print_time.c
+++ b/src/print_time.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <locale.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
@@ -33,7 +34,7 @@ void set_timezone(const char *tz) {
}
}
-void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *format, const char *tz, const char *format_time, time_t t) {
+void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *format, const char *tz, const char *locale, const char *format_time, time_t t) {
const char *walk;
char *outwalk = buffer;
struct tm tm;
@@ -45,6 +46,10 @@ void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *
set_timezone(tz);
localtime_r(&t, &tm);
+ if (locale != NULL) {
+ setlocale(LC_ALL, locale);
+ }
+
if (format_time == NULL) {
strftime(timebuf, sizeof(timebuf), format, &tm);
maybe_escape_markup(timebuf, &outwalk);
@@ -63,6 +68,10 @@ void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *
}
}
+ if (locale != NULL) {
+ setlocale(LC_ALL, "");
+ }
+
*outwalk = '\0';
OUTPUT_FULL_TEXT(buffer);
}