]> git.sur5r.net Git - i3/i3status/blob - src/print_time.c
Implement the i3bar JSON protocol
[i3/i3status] / src / print_time.c
1 // vim:ts=8:expandtab
2 #include <time.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5
6 #include "i3status.h"
7
8 void print_time(const char *format, struct tm *current_tm) {
9         static char part[512];
10         /* Get date & time */
11         if (current_tm == NULL) {
12                 return;
13         }
14         if (output_format == O_I3BAR)
15                 printf("{\"name\":\"time\", \"full_text\":\"");
16         (void)strftime(part, sizeof(part), format, current_tm);
17         printf("%s", part);
18         if (output_format == O_I3BAR)
19                 printf("\"}");
20 }