summaryrefslogtreecommitdiff
path: root/src/print_time.c
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2012-03-25 20:55:55 +0200
committerMichael Stapelberg <michael@stapelberg.de>2012-03-25 22:05:00 +0200
commit12b1bfa9b8485de88b0bda82821c021aee197673 (patch)
treeb6d87f7ed5876109863a6599992e351509a30d58 /src/print_time.c
parentafb0525235c57fc4896633003a45bfb013af38d2 (diff)
Properly output JSON with libyajl
Diffstat (limited to 'src/print_time.c')
-rw-r--r--src/print_time.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/print_time.c b/src/print_time.c
index 3c48d3f..a1bb34c 100644
--- a/src/print_time.c
+++ b/src/print_time.c
@@ -2,19 +2,16 @@
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
+#include <yajl/yajl_gen.h>
#include "i3status.h"
-void print_time(const char *format, struct tm *current_tm) {
- static char part[512];
- /* Get date & time */
- if (current_tm == NULL) {
+void print_time(yajl_gen json_gen, char *buffer, const char *format, struct tm *current_tm) {
+ char *outwalk = buffer;
+ if (current_tm == NULL)
return;
- }
- if (output_format == O_I3BAR)
- printf("{\"name\":\"time\", \"full_text\":\"");
- (void)strftime(part, sizeof(part), format, current_tm);
- printf("%s", part);
- if (output_format == O_I3BAR)
- printf("\"}");
+ /* Get date & time */
+ outwalk += strftime(outwalk, 4095, format, current_tm);
+ *outwalk = '\0';
+ OUTPUT_FULL_TEXT(buffer);
}