1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 00:33:13 +02:00

Add new option weechat.look.time_format to customize default format for date/time displayed (localized date by default), add function weechat_util_get_time_string in plugin API (patch #6914)

This commit is contained in:
Sebastien Helleu
2010-02-09 17:19:14 +01:00
parent daee18621e
commit 7850668327
30 changed files with 507 additions and 217 deletions
+1 -2
View File
@@ -338,8 +338,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
/* time */
now = time (NULL);
snprintf (buf, sizeof (buf), "%s",
ctime (&now));
snprintf (buf, sizeof (buf), "%s", ctime (&now));
buf[strlen (buf) - 1] = '\0';
temp = weechat_string_replace (res, "$time", buf);
free (res);
+10 -10
View File
@@ -1095,8 +1095,8 @@ irc_protocol_cmd_pong (struct t_irc_server *server, const char *command,
/* calculate lag (time diff with lag check) */
old_lag = server->lag;
gettimeofday (&tv, NULL);
server->lag = (int) weechat_timeval_diff (&(server->lag_check_time),
&tv);
server->lag = (int) weechat_util_timeval_diff (&(server->lag_check_time),
&tv);
if (old_lag != server->lag)
weechat_bar_item_update ("lag");
@@ -2122,7 +2122,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command,
IRC_COLOR_CHAT,
NG_("second", "seconds", sec),
IRC_COLOR_CHAT_CHANNEL,
ctime (&datetime));
weechat_util_get_time_string (&datetime));
}
else
{
@@ -2150,7 +2150,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command,
IRC_COLOR_CHAT,
NG_("second", "seconds", sec),
IRC_COLOR_CHAT_CHANNEL,
ctime (&datetime));
weechat_util_get_time_string (&datetime));
}
return WEECHAT_RC_OK;
@@ -2422,7 +2422,7 @@ irc_protocol_cmd_329 (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "irc_numeric"),
_("%sChannel created on %s"),
weechat_prefix ("network"),
ctime (&datetime));
weechat_util_get_time_string (&datetime));
ptr_channel->display_creation_date = 0;
}
}
@@ -2435,7 +2435,7 @@ irc_protocol_cmd_329 (struct t_irc_server *server, const char *command,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT,
ctime (&datetime));
weechat_util_get_time_string (&datetime));
}
return WEECHAT_RC_OK;
@@ -2587,7 +2587,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command,
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
argv[4],
IRC_COLOR_CHAT,
ctime (&datetime));
weechat_util_get_time_string (&datetime));
}
else
{
@@ -2601,7 +2601,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command,
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
argv[4],
IRC_COLOR_CHAT,
ctime (&datetime));
weechat_util_get_time_string (&datetime));
}
return WEECHAT_RC_OK;
@@ -2776,7 +2776,7 @@ irc_protocol_cmd_348 (struct t_irc_server *server, const char *command,
irc_protocol_get_address_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
ctime (&datetime));
weechat_util_get_time_string (&datetime));
}
else
{
@@ -3279,7 +3279,7 @@ irc_protocol_cmd_367 (struct t_irc_server *server, const char *command,
irc_protocol_get_address_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
ctime (&datetime));
weechat_util_get_time_string (&datetime));
}
else
{
+2 -2
View File
@@ -1751,8 +1751,8 @@ irc_server_timer_cb (void *data, int remaining_calls)
&& (weechat_config_integer (irc_config_network_lag_disconnect) > 0))
{
gettimeofday (&tv, NULL);
diff = (int) weechat_timeval_diff (&(ptr_server->lag_check_time),
&tv);
diff = (int) weechat_util_timeval_diff (&(ptr_server->lag_check_time),
&tv);
if (diff / 1000 > weechat_config_integer (irc_config_network_lag_disconnect) * 60)
{
weechat_printf (ptr_server->buffer,
+4 -3
View File
@@ -409,9 +409,10 @@ plugin_load (const char *filename)
new_plugin->exec_on_files = &util_exec_on_files;
new_plugin->file_get_content = &util_file_get_content;
new_plugin->timeval_cmp = &util_timeval_cmp;
new_plugin->timeval_diff = &util_timeval_diff;
new_plugin->timeval_add = &util_timeval_add;
new_plugin->util_timeval_cmp = &util_timeval_cmp;
new_plugin->util_timeval_diff = &util_timeval_diff;
new_plugin->util_timeval_add = &util_timeval_add;
new_plugin->util_get_time_string = &util_get_time_string;
new_plugin->list_new = &weelist_new;
new_plugin->list_add = &weelist_add;
+13 -10
View File
@@ -34,7 +34,7 @@ struct t_weelist;
struct timeval;
/* API version (used to check that plugin has same API and can be loaded) */
#define WEECHAT_PLUGIN_API_VERSION "20091218-01"
#define WEECHAT_PLUGIN_API_VERSION "20100209-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -199,9 +199,10 @@ struct t_weechat_plugin
char *(*file_get_content) (const char *filename);
/* util */
int (*timeval_cmp) (struct timeval *tv1, struct timeval *tv2);
long (*timeval_diff) (struct timeval *tv1, struct timeval *tv2);
void (*timeval_add) (struct timeval *tv, long interval);
int (*util_timeval_cmp) (struct timeval *tv1, struct timeval *tv2);
long (*util_timeval_diff) (struct timeval *tv1, struct timeval *tv2);
void (*util_timeval_add) (struct timeval *tv, long interval);
char *(*util_get_time_string) (const time_t *date);
/* sorted lists */
struct t_weelist *(*list_new) ();
@@ -765,12 +766,14 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->file_get_content(__filename)
/* util */
#define weechat_timeval_cmp(__time1, __time2) \
weechat_plugin->timeval_cmp(__time1, __time2)
#define weechat_timeval_diff(__time1, __time2) \
weechat_plugin->timeval_diff(__time1, __time2)
#define weechat_timeval_add(__time, __interval) \
weechat_plugin->timeval_add(__time, __interval)
#define weechat_util_timeval_cmp(__time1, __time2) \
weechat_plugin->util_timeval_cmp(__time1, __time2)
#define weechat_util_timeval_diff(__time1, __time2) \
weechat_plugin->util_timeval_diff(__time1, __time2)
#define weechat_util_timeval_add(__time, __interval) \
weechat_plugin->util_timeval_add(__time, __interval)
#define weechat_util_get_time_string(__date) \
weechat_plugin->util_get_time_string(__date)
/* sorted list */
#define weechat_list_new() \