diff options
author | nicm <nicm> | 2019-03-14 23:14:27 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-03-14 23:14:27 +0000 |
commit | 10d60faba5d06db707a752be47dbb12abd4b8168 (patch) | |
tree | 6d5b681af6fde11533c5bd1f809e94e0ff94246d /format.c | |
parent | bace79a5715932f093d4c17db5d49af8e6594916 (diff) | |
download | rtmux-10d60faba5d06db707a752be47dbb12abd4b8168.tar.gz rtmux-10d60faba5d06db707a752be47dbb12abd4b8168.tar.bz2 rtmux-10d60faba5d06db707a752be47dbb12abd4b8168.zip |
Store the time in the format tree rather than passing it around.
Diffstat (limited to 'format.c')
-rw-r--r-- | format.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -121,6 +121,7 @@ struct format_tree { struct client *client; u_int tag; int flags; + time_t time; RB_HEAD(format_entry_tree, format_entry) tree; }; @@ -682,6 +683,7 @@ format_create(struct client *c, struct cmdq_item *item, int tag, int flags) ft->tag = tag; ft->flags = flags; + ft->time = time(NULL); format_add_cb(ft, "host", format_cb_host); format_add_cb(ft, "host_short", format_cb_host_short); @@ -1437,7 +1439,7 @@ done: value = new; } else if (modifiers & FORMAT_EXPANDTIME) { - new = format_expand_time(ft, value, 0); + new = format_expand_time(ft, value); free(value); value = new; } @@ -1483,7 +1485,7 @@ fail: /* Expand keys in a template, passing through strftime first. */ char * -format_expand_time(struct format_tree *ft, const char *fmt, time_t t) +format_expand_time(struct format_tree *ft, const char *fmt) { struct tm *tm; char s[2048]; @@ -1491,10 +1493,7 @@ format_expand_time(struct format_tree *ft, const char *fmt, time_t t) if (fmt == NULL || *fmt == '\0') return (xstrdup("")); - if (t == 0) - t = time(NULL); - tm = localtime(&t); - + tm = localtime(&ft->time); if (strftime(s, sizeof s, fmt, tm) == 0) return (xstrdup("")); |