summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@users.noreply.github.com>2015-03-23 22:12:21 +0100
committerMichael Stapelberg <stapelberg@users.noreply.github.com>2015-03-23 22:12:21 +0100
commitbf223d9b61498a6b1e723bacb007545a696141fe (patch)
tree38d20a2a364328ed7bebd2b5fbc079deba9d624e
parent3f9d4c6d897b44be3971af7229bf07e425d0915f (diff)
parent0a84bcb74aeef2efc2f5ccc1cfc674242f311cd2 (diff)
Merge pull request #12 from Airblader/feature-tztime-instance
Pass the "instance" JSON property key for tztime blocks
-rw-r--r--i3status.c4
-rw-r--r--include/i3status.h2
-rw-r--r--src/print_time.c5
3 files changed, 7 insertions, 4 deletions
diff --git a/i3status.c b/i3status.c
index 8749933..bc8f35f 100644
--- a/i3status.c
+++ b/i3status.c
@@ -627,13 +627,13 @@ int main(int argc, char *argv[]) {
CASE_SEC("time") {
SEC_OPEN_MAP("time");
- print_time(json_gen, buffer, cfg_getstr(sec, "format"), NULL, tv.tv_sec);
+ print_time(json_gen, buffer, NULL, cfg_getstr(sec, "format"), NULL, tv.tv_sec);
SEC_CLOSE_MAP;
}
CASE_SEC_TITLE("tztime") {
SEC_OPEN_MAP("tztime");
- print_time(json_gen, buffer, cfg_getstr(sec, "format"), cfg_getstr(sec, "timezone"), tv.tv_sec);
+ print_time(json_gen, buffer, title, cfg_getstr(sec, "format"), cfg_getstr(sec, "timezone"), tv.tv_sec);
SEC_CLOSE_MAP;
}
diff --git a/include/i3status.h b/include/i3status.h
index 0985180..a61d966 100644
--- a/include/i3status.h
+++ b/include/i3status.h
@@ -183,7 +183,7 @@ const char *first_eth_interface(const net_type_t type);
void print_ipv6_info(yajl_gen json_gen, char *buffer, const char *format_up, const char *format_down);
void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const char *format, const char *format_not_mounted, const char *prefix_type, const char *threshold_type, const double low_threshold);
void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char *path, const char *format, const char *format_down, const char *status_chr, const char *status_bat, const char *status_full, int low_threshold, char *threshold_type, bool last_full_capacity, bool integer_battery_capacity, bool hide_seconds);
-void print_time(yajl_gen json_gen, char *buffer, const char *format, const char *tz, time_t t);
+void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *format, const char *tz, time_t t);
void print_ddate(yajl_gen json_gen, char *buffer, const char *format, time_t t);
const char *get_ip_addr();
void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down);
diff --git a/src/print_time.c b/src/print_time.c
index edbc828..c70a09c 100644
--- a/src/print_time.c
+++ b/src/print_time.c
@@ -33,10 +33,13 @@ void set_timezone(const char *tz) {
}
}
-void print_time(yajl_gen json_gen, char *buffer, const char *format, const char *tz, time_t t) {
+void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *format, const char *tz, time_t t) {
char *outwalk = buffer;
struct tm tm;
+ if (title != NULL)
+ INSTANCE(title);
+
/* Convert time and format output. */
set_timezone(tz);
localtime_r(&t, &tm);