2
0
Fork 0
forked from zynk/zynk

fix: use localtime for !seen timestamps instead of UTC

seen_update() used SQLite's datetime('now') which returns UTC, causing
!seen to show wrong times (e.g. 16:00 instead of 18:00 on UTC+2).
Changed to datetime('now','localtime') so seen timestamps match the
system's local time.

Version bumped to 0.36.1.
This commit is contained in:
Johannes Findeisen 2026-07-20 22:24:21 +02:00
commit a260a93eb1
2 changed files with 8 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2026.07.20 – Fix !seen showing UTC instead of local time.
- Fixed `!seen` command storing UTC timestamps instead of local time: `seen_update()` used `datetime('now')` which returns UTC, causing `!seen <nick>` to display a time offset by the server's timezone difference (e.g. 16:00 instead of 18:00 on a UTC+2 system). Changed to `datetime('now','localtime')` so seen timestamps match the system's local time.
- Version bumped to 0.36.1.
2026.07.20 – Add !gitlog command.
- Added `!gitlog [count]` command: displays recent git commits of the zynk project using `git log --oneline`. Defaults to 5 commits (`GITLOG_COUNT`), accepts 1–20 as count. Each commit is sent as a separate IRC message.

6
zynk.c
View file

@ -29,7 +29,7 @@ int asprintf(char **, const char *, ...);
/* ---- constants ---- */
#define VERSION "0.36.0"
#define VERSION "0.36.1"
#define DEFAULT_SERVER "irc.libera.chat"
#define OPENCODE_BIN "/usr/bin/opencode"
#define CLR_RESET "\033[0m"
@ -605,8 +605,8 @@ static void ai_reset(long long id) {
static void seen_update(const char *nick, const char *channel, const char *action) {
void *stmt;
const char *sql = "INSERT INTO seen(nick,last_seen,last_channel,last_action)"
" VALUES(?,datetime('now'),?,?)"
" ON CONFLICT(nick) DO UPDATE SET last_seen=datetime('now'),"
" VALUES(?,datetime('now','localtime'),?,?)"
" ON CONFLICT(nick) DO UPDATE SET last_seen=datetime('now','localtime'),"
" last_channel=excluded.last_channel, last_action=excluded.last_action";
if (db_prepare(DB, sql, -1, &stmt, NULL) != SQLITE_OK) return;
db_bind_text(stmt, 1, nick, -1, SQLITE_STATIC);