diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-01-27 12:15:40 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-01-27 16:53:53 +0100 |
commit | 2469dc6df95713d15eb993438594db14416141b2 (patch) | |
tree | be0bc7e858630a9b4d4aeb0e14347d5f29f3b5ca /src/core/wee-eval.c | |
parent | e3af6a91d4e7b2de38c0b60b5c1bb0344dc00e02 (diff) | |
download | weechat-2469dc6df95713d15eb993438594db14416141b2.zip |
core: use function util_strftimeval in evaluation of expression `date:xxx`
Diffstat (limited to 'src/core/wee-eval.c')
-rw-r--r-- | src/core/wee-eval.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index a1fc10538..4f0f928ef 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -28,6 +28,7 @@ #include <stdarg.h> #include <regex.h> #include <time.h> +#include <sys/time.h> #include "weechat.h" #include "wee-eval.h" @@ -39,6 +40,7 @@ #include "wee-secure.h" #include "wee-string.h" #include "wee-utf8.h" +#include "wee-util.h" #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" #include "../gui/gui-color.h" @@ -988,19 +990,13 @@ char * eval_string_date (const char *text) { char str_value[512]; - time_t date; - struct tm *date_tmp; + struct timeval tv_now; int rc; - date = time (NULL); - date_tmp = localtime (&date); - if (!date_tmp) - return strdup (""); - - rc = (int) strftime (str_value, sizeof (str_value), - (text[0] == ':') ? text + 1 : "%F %T", - date_tmp); - + gettimeofday (&tv_now, NULL); + rc = util_strftimeval (str_value, sizeof (str_value), + (text[0] == ':') ? text + 1 : "%F %T", + &tv_now); return strdup ((rc > 0) ? str_value : ""); } |