6 #include <yajl/yajl_gen.h>
7 #include <yajl/yajl_version.h>
11 static bool local_timezone_init = false;
12 static const char *local_timezone = NULL;
13 static const char *current_timezone = NULL;
15 void set_timezone(const char *tz) {
16 if (!local_timezone_init) {
17 /* First call, initialize. */
18 local_timezone = getenv("TZ");
19 local_timezone_init = true;
21 if (tz == NULL || tz[0] == '\0') {
22 /* User wants localtime. */
25 if (tz != current_timezone) {
32 current_timezone = tz;
36 void print_time(yajl_gen json_gen, char *buffer, const char *format, const char *tz, time_t t) {
37 char *outwalk = buffer;
40 /* Convert time and format output. */
43 outwalk += strftime(outwalk, 4095, format, &tm);
45 OUTPUT_FULL_TEXT(buffer);