summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/special_vars.txt2
-rw-r--r--src/core/expandos.c21
-rw-r--r--src/fe-common/core/module-formats.c2
3 files changed, 21 insertions, 4 deletions
diff --git a/docs/special_vars.txt b/docs/special_vars.txt
index 41b63925..1e7ac204 100644
--- a/docs/special_vars.txt
+++ b/docs/special_vars.txt
@@ -76,7 +76,7 @@ $A .. $Z is important.
$W current working directory
$X your /userhost $N address (user@host)
$Y value of REALNAME
- $Z time of day (hh:mm)
+ $Z time of day (hh:mm, can be changed with /SET timestamp_format)
$$ a literal '$'
$sysname system name (eg. Linux)
diff --git a/src/core/expandos.c b/src/core/expandos.c
index fe01b8df..68d14dcc 100644
--- a/src/core/expandos.c
+++ b/src/core/expandos.c
@@ -54,6 +54,7 @@ static time_t client_start_time;
static char *last_sent_msg, *last_sent_msg_body;
static char *last_privmsg_from, *last_public_from;
static char *sysname, *sysrelease;
+static const char *timestamp_format;
#define CHAR_EXPANDOS_COUNT \
((int) (sizeof(char_expandos) / sizeof(char_expandos[0])))
@@ -348,12 +349,18 @@ static char *expando_realname(SERVER_REC *server, void *item, int *free_ret)
/* time of day (hh:mm) */
static char *expando_time(SERVER_REC *server, void *item, int *free_ret)
{
- time_t now = time(NULL);
+ time_t now;
struct tm *tm;
+ char str[256];
+ now = time(NULL);
tm = localtime(&now);
+
+ if (strftime(str, sizeof(str), timestamp_format, tm) == 0)
+ return "";
+
*free_ret = TRUE;
- return g_strdup_printf("%02d:%02d", tm->tm_hour, tm->tm_min);
+ return g_strdup(str);
}
/* a literal '$' */
@@ -430,12 +437,18 @@ static int sig_timer(void)
return 1;
}
+static void read_settings(void)
+{
+ timestamp_format = settings_get_str("timestamp_format");
+}
+
void expandos_init(void)
{
#ifdef HAVE_SYS_UTSNAME_H
struct utsname un;
#endif
settings_add_str("misc", "STATUS_OPER", "*");
+ settings_add_str("misc", "timestamp_format", "%H:%M");
client_start_time = time(NULL);
last_sent_msg = NULL; last_sent_msg_body = NULL;
@@ -525,10 +538,13 @@ void expandos_init(void)
"window changed", EXPANDO_ARG_NONE,
"window server changed", EXPANDO_ARG_WINDOW, NULL);
+ read_settings();
+
timer_tag = g_timeout_add(1000, (GSourceFunc) sig_timer, NULL);
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
signal_add("message own_private", (SIGNAL_FUNC) sig_message_own_private);
+ signal_add("setup changed", (SIGNAL_FUNC) read_settings);
}
void expandos_deinit(void)
@@ -554,4 +570,5 @@ void expandos_deinit(void)
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
signal_remove("message own_private", (SIGNAL_FUNC) sig_message_own_private);
+ signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
}
diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c
index fef4e588..1762712c 100644
--- a/src/fe-common/core/module-formats.c
+++ b/src/fe-common/core/module-formats.c
@@ -29,7 +29,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "line_start", "{line_start}", 0 },
{ "line_start_irssi", "{line_start}{hilight Irssi:} ", 0 },
- { "timestamp", "{timestamp $[-2.0]3:$[-2.0]4} ", 6, { 1, 1, 1, 1, 1, 1 } },
+ { "timestamp", "{timestamp $Z} ", 6, { 1, 1, 1, 1, 1, 1 } },
{ "servertag", "[$0] ", 1, { 0 } },
{ "daychange", "Day changed to $[-2.0]{0} $3 $2", 4, { 1, 1, 1, 0 } },
{ "talking_with", "You are now talking with {nick $0}", 1, { 0 } },