cio

a simple irc client
Download | Log | Files | Refs | README | LICENSE

commit 6f9cce569ef0ef9c0f7f19df12a96ea7ec3f6ded
parent 07020c66ff3893a9a7cb8ab9d6b2ad0d5c092671
Author: Andrew Kloet <andrew@kloet.net>
Date:   Tue, 28 Apr 2026 17:10:37 -0400

print when the day has changed since last message

Diffstat:
Mcio.c | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/cio.c b/cio.c @@ -95,11 +95,12 @@ static struct { static struct Chan { char name[ChanLen]; char *buf, *eol; - int n; /* Scroll offset. */ - size_t sz; /* Size of buf. */ - char high; /* Nick highlight. */ - char new; /* New message. */ - char join; /* Channel was 'j'-oined. */ + int n; /* Scroll offset. */ + int last_mday; /* Tracks tm_mday of last message */ + size_t sz; /* Size of buf. */ + char high; /* Nick highlight. */ + char new; /* New message. */ + char join; /* Channel was 'j'-oined. */ } chl[MaxChans]; static struct { @@ -382,6 +383,7 @@ chadd(const char *name, int joined) chl[nch].eol = chl[nch].buf; chl[nch].n = 0; chl[nch].join = joined; + chl[nch].last_mday = -1; if (joined) ch = nch; nch++; @@ -465,6 +467,13 @@ pushf(int cn, const char *fmt, ...) t = time(0); if (!(tm = localtime(&t))) die("cio: localtime failed"); + if (c->last_mday == -1) { + c->last_mday = tm->tm_mday; + } else if (c->last_mday != tm->tm_mday) { + c->last_mday = tm->tm_mday; + pushf(cn, "--- Day changed to %04d-%02d-%02d Anno Domini ---", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); + } n = strftime(c->eol, LineLen, DATEFMT, tm); if (!(gmtm = gmtime(&t))) die("cio: gmtime failed");