summaryrefslogtreecommitdiff
path: root/src/print_time.c
blob: 3c48d3f8e5a1188ffeb20db90aca17c88d32a81a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// vim:ts=8:expandtab
#include <time.h>
#include <stdio.h>
#include <stdlib.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) {
                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("\"}");
}