diff --git a/src/conky.c b/src/conky.c index 0d1b9576..b0d20aff 100644 --- a/src/conky.c +++ b/src/conky.c @@ -956,13 +956,6 @@ void generate_text_internal(char *p, int p_max_size, DO_JUMP; } } - OBJ(format_time) { - char buf[max_user_text]; - - generate_text_internal(buf, max_user_text, *obj->sub, cur); - obj->data.s = buf; - print_format_time(obj, p, p_max_size); - } OBJ(nodename) { snprintf(p, p_max_size, "%s", cur->uname_s.nodename); } diff --git a/src/core.c b/src/core.c index c48a6399..1bbd382f 100644 --- a/src/core.c +++ b/src/core.c @@ -826,6 +826,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ_ARG(format_time, 0, "format_time needs a pid as argument") obj->sub = malloc(sizeof(struct text_object)); extract_variable_text_internal(obj->sub, arg); + obj->callbacks.print = &print_format_time; END OBJ(nodename, 0) END OBJ_ARG(cmdline_to_pid, 0, "cmdline_to_pid needs a command line as argument") scan_cmdline_to_pid_arg(obj, arg, free_at_crash); diff --git a/src/timeinfo.c b/src/timeinfo.c index f48d9b78..8a7255dd 100644 --- a/src/timeinfo.c +++ b/src/timeinfo.c @@ -155,7 +155,7 @@ void free_tztime(struct text_object *obj) //all chars after the ending " and between the seconds and the starting " are silently //ignored, this is wanted behavior, not a bug, so don't "fix" this. -void print_format_time(struct text_object *obj, char *p, unsigned int p_max_size) { +static void do_format_time(struct text_object *obj, char *p, unsigned int p_max_size) { double seconds; char *currentchar, *temp; unsigned int output_length = 0; @@ -305,3 +305,13 @@ void print_format_time(struct text_object *obj, char *p, unsigned int p_max_size NORM_ERR("$format_time didn't receive a time in seconds as first argument") } } + +void print_format_time(struct text_object *obj, char *p, int p_max_size) +{ + char buf[max_user_text]; + + generate_text_internal(buf, max_user_text, *obj->sub, &info); + obj->data.s = buf; + do_format_time(obj, p, p_max_size); +} + diff --git a/src/timeinfo.h b/src/timeinfo.h index 7988cda9..88fa6ed2 100644 --- a/src/timeinfo.h +++ b/src/timeinfo.h @@ -45,11 +45,10 @@ void scan_tztime(struct text_object *, const char *); void print_time(struct text_object *, char *, int); void print_utime(struct text_object *, char *, int); void print_tztime(struct text_object *, char *, int); +void print_format_time(struct text_object *obj, char *p, int p_max_size); /* free object data */ void free_time(struct text_object *); void free_tztime(struct text_object *); #endif /* _TIMEINFO_H */ - -void print_format_time(struct text_object *obj, char *p, int p_max_size);