]> git.sur5r.net Git - i3/i3status/blob - src/print_time.c
Properly output JSON with libyajl
[i3/i3status] / src / print_time.c
1 // vim:ts=8:expandtab
2 #include <time.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <yajl/yajl_gen.h>
6
7 #include "i3status.h"
8
9 void print_time(yajl_gen json_gen, char *buffer, const char *format, struct tm *current_tm) {
10         char *outwalk = buffer;
11         if (current_tm == NULL)
12                 return;
13         /* Get date & time */
14         outwalk += strftime(outwalk, 4095, format, current_tm);
15         *outwalk = '\0';
16         OUTPUT_FULL_TEXT(buffer);
17 }