diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-06-30 14:19:00 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-06-30 14:19:00 +0200 |
commit | 08c3c848bd2711c983c08c86043b6b2506f02880 (patch) | |
tree | 3cc70fc95b6a0db4e099e6ac2e9a38d99d581d6d /src/plugins | |
parent | 00a9028f42537198d2e7d5d57907607b8713f138 (diff) | |
download | weechat-08c3c848bd2711c983c08c86043b6b2506f02880.zip |
irc: add option irc.look.ctcp_time_format to customize reply to CTCP TIME (task #12150)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-config.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-ctcp.c | 10 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 9c47883aa..4e695140f 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -56,6 +56,7 @@ struct t_config_option *irc_config_look_color_nicks_in_names; struct t_config_option *irc_config_look_color_nicks_in_nicklist; struct t_config_option *irc_config_look_color_nicks_in_server_messages; struct t_config_option *irc_config_look_color_pv_nick_like_channel; +struct t_config_option *irc_config_look_ctcp_time_format; struct t_config_option *irc_config_look_server_buffer; struct t_config_option *irc_config_look_new_channel_position; struct t_config_option *irc_config_look_new_pv_position; @@ -2049,6 +2050,12 @@ irc_config_init () N_("use same nick color for channel and private"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_ctcp_time_format = weechat_config_new_option ( + irc_config_file, ptr_section, + "ctcp_time_format", "string", + N_("time format used in answer to message CTCP TIME (see man strftime " + "for date/time specifiers)"), + NULL, 0, 0, "%a, %d %b %Y %T %z", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_server_buffer = weechat_config_new_option ( irc_config_file, ptr_section, "server_buffer", "integer", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index c9331a3a1..213ddb9c8 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -81,6 +81,7 @@ extern struct t_config_option *irc_config_look_color_nicks_in_names; extern struct t_config_option *irc_config_look_color_nicks_in_nicklist; extern struct t_config_option *irc_config_look_color_nicks_in_server_messages; extern struct t_config_option *irc_config_look_color_pv_nick_like_channel; +extern struct t_config_option *irc_config_look_ctcp_time_format; extern struct t_config_option *irc_config_look_server_buffer; extern struct t_config_option *irc_config_look_new_channel_position; extern struct t_config_option *irc_config_look_new_pv_position; diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 6094d7bc4..518765997 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -27,6 +27,7 @@ #include <sys/time.h> #include <time.h> #include <sys/utsname.h> +#include <locale.h> #include "../weechat-plugin.h" #include "irc.h" @@ -330,6 +331,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format) char *res, *temp; const char *info; time_t now; + struct tm *local_time; char buf[1024]; struct utsname *buf_uname; @@ -390,8 +392,12 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format) /* time */ now = time (NULL); - snprintf (buf, sizeof (buf), "%s", ctime (&now)); - buf[strlen (buf) - 1] = '\0'; + local_time = localtime (&now); + setlocale (LC_ALL, "C"); + strftime (buf, sizeof (buf), + weechat_config_string (irc_config_look_ctcp_time_format), + local_time); + setlocale (LC_ALL, ""); temp = weechat_string_replace (res, "$time", buf); free (res); if (!temp) |