mirror of
https://github.com/irssi/irssi.git
synced 2024-09-08 04:26:01 -04:00
/FORMAT timestamp and /FORMAT day_changed use now strftime()-style
formats for specifying time. %x is still treated as color format, so you'll need to escape them with another % (%%H:%%S). The $ parameters don't work anymore. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2142 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
7ae96f540d
commit
ff16e15389
@ -500,18 +500,31 @@ static void sig_server_disconnected(SERVER_REC *server)
|
||||
}
|
||||
}
|
||||
|
||||
static void window_print_daychange(WINDOW_REC *window, struct tm *tm)
|
||||
{
|
||||
THEME_REC *theme;
|
||||
TEXT_DEST_REC dest;
|
||||
char *format, str[256];
|
||||
|
||||
theme = active_win->theme != NULL ? active_win->theme : current_theme;
|
||||
format_create_dest(&dest, NULL, NULL, MSGLEVEL_NEVER, window);
|
||||
format = format_get_text_theme(theme, MODULE_NAME, &dest,
|
||||
TXT_DAYCHANGE);
|
||||
if (strftime(str, sizeof(str), format, tm) <= 0)
|
||||
str[0] = '\0';
|
||||
g_free(format);
|
||||
|
||||
printtext_string_window(window, MSGLEVEL_NEVER, str);
|
||||
}
|
||||
|
||||
static void sig_print_text(void)
|
||||
{
|
||||
GSList *tmp;
|
||||
char month[100];
|
||||
time_t t;
|
||||
struct tm *tm;
|
||||
|
||||
t = time(NULL);
|
||||
tm = localtime(&t);
|
||||
if (strftime(month, sizeof(month), "%b", tm) <= 0)
|
||||
month[0] = '\0';
|
||||
|
||||
if (tm->tm_hour != 0 || tm->tm_min != 0)
|
||||
return;
|
||||
|
||||
@ -519,11 +532,8 @@ static void sig_print_text(void)
|
||||
signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
|
||||
|
||||
/* day changed, print notice about it to every window */
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
printformat_window(tmp->data, MSGLEVEL_NEVER, TXT_DAYCHANGE,
|
||||
tm->tm_mday, tm->tm_mon+1,
|
||||
1900+tm->tm_year, month);
|
||||
}
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next)
|
||||
window_print_daychange(tmp->data, tm);
|
||||
}
|
||||
|
||||
static int sig_check_daychange(void)
|
||||
|
@ -579,6 +579,7 @@ char *format_get_level_tag(THEME_REC *theme, TEXT_DEST_REC *dest)
|
||||
|
||||
static char *get_timestamp(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t)
|
||||
{
|
||||
char *format, str[256];
|
||||
struct tm *tm;
|
||||
int diff;
|
||||
|
||||
@ -602,10 +603,12 @@ static char *get_timestamp(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t)
|
||||
}
|
||||
|
||||
tm = localtime(&t);
|
||||
return format_get_text_theme(theme, MODULE_NAME, dest, TXT_TIMESTAMP,
|
||||
tm->tm_year+1900,
|
||||
tm->tm_mon+1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
format = format_get_text_theme(theme, MODULE_NAME, dest,
|
||||
TXT_TIMESTAMP);
|
||||
if (strftime(str, sizeof(str), format, tm) <= 0)
|
||||
str[0] = '\0';
|
||||
g_free(format);
|
||||
return g_strdup(str);
|
||||
}
|
||||
|
||||
static char *get_server_tag(THEME_REC *theme, TEXT_DEST_REC *dest)
|
||||
|
@ -29,9 +29,9 @@ FORMAT_REC fecommon_core_formats[] = {
|
||||
|
||||
{ "line_start", "{line_start}", 0 },
|
||||
{ "line_start_irssi", "{line_start}{hilight Irssi:} ", 0 },
|
||||
{ "timestamp", "{timestamp $Z} ", 6, { 1, 1, 1, 1, 1, 1 } },
|
||||
{ "timestamp", "{timestamp $Z} ", 0 },
|
||||
{ "servertag", "[$0] ", 1, { 0 } },
|
||||
{ "daychange", "Day changed to $[-2.0]{0} $3 $2", 4, { 1, 1, 1, 0 } },
|
||||
{ "daychange", "Day changed to %%d %%b %%Y", 0 },
|
||||
{ "talking_with", "You are now talking with {nick $0}", 1, { 0 } },
|
||||
{ "refnum_too_low", "Window number must be greater than 1", 0 },
|
||||
{ "error_server_sticky", "Window's server is sticky and it cannot be changed without -unsticky option", 0 },
|
||||
|
Loading…
Reference in New Issue
Block a user