Fix !zynk key-value timestamps to use localtime instead of UTC
- Fixed db_set() using datetime('now') which returns UTC, causing
!zynk <key> to display timestamps offset by the server's timezone
difference. Changed to datetime('now','localtime') so timestamps
match the system's local time.
- Also fixed db_rotate_history() (AI query context rotation) and the
zynk/tell table DEFAULT clauses to use localtime.
- Same pattern as the !seen fix in 0.39.1.
(0.40.1)
This commit is contained in:
parent
739e3622b5
commit
c1c9f0208b
4 changed files with 13 additions and 8 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
2026.07.23 - Fix !zynk key-value timestamps to use localtime. (0.40.1)
|
||||||
|
|
||||||
|
- Fixed `!zynk key = value` storing UTC timestamps instead of localtime: `db_set()` and the `zynk` table default used `datetime('now')` which returns UTC, causing `!zynk <key>` to display a timestamp offset by the server's timezone difference. Changed to `datetime('now','localtime')` so timestamps match the system's local time.
|
||||||
|
- Also fixed `db_rotate_history()` (used by AI query context) and the `tell` table default to use localtime.
|
||||||
|
|
||||||
2026.07.23 - Commit links for !gitlog, full changelog link for !changelog, CMake, multi-file refactor. (0.40.0)
|
2026.07.23 - Commit links for !gitlog, full changelog link for !changelog, CMake, multi-file refactor. (0.40.0)
|
||||||
|
|
||||||
- `!gitlog` now shows a link to each commit in the repository (e.g. `184d4c4 Fix whitespace... - https://...`), using the git remote URL converted from SSH/SCP to HTTPS.
|
- `!gitlog` now shows a link to each commit in the repository (e.g. `184d4c4 Fix whitespace... - https://...`), using the git remote URL converted from SSH/SCP to HTTPS.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
project(zynk VERSION 0.40.0 LANGUAGES C)
|
project(zynk VERSION 0.40.1 LANGUAGES C)
|
||||||
|
|
||||||
# Prefer C99; the code is compatible with C99/C11
|
# Prefer C99; the code is compatible with C99/C11
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
|
||||||
12
db.h
12
db.h
|
|
@ -100,7 +100,7 @@ int db_init(void) {
|
||||||
}
|
}
|
||||||
const char *sql_zynk = "CREATE TABLE IF NOT EXISTS zynk ("
|
const char *sql_zynk = "CREATE TABLE IF NOT EXISTS zynk ("
|
||||||
"key TEXT PRIMARY KEY, value TEXT NOT NULL, "
|
"key TEXT PRIMARY KEY, value TEXT NOT NULL, "
|
||||||
"nick TEXT NOT NULL, updated_at TEXT DEFAULT (datetime('now')))";
|
"nick TEXT NOT NULL, updated_at TEXT DEFAULT (datetime('now','localtime')))";
|
||||||
char *err = NULL;
|
char *err = NULL;
|
||||||
if (db_exec(DB, sql_zynk, NULL, NULL, &err) != SQLITE_OK) {
|
if (db_exec(DB, sql_zynk, NULL, NULL, &err) != SQLITE_OK) {
|
||||||
fprintf(stderr, CLR_RED "SQL: %s" CLR_RESET "\n", err ? err : "unknown error");
|
fprintf(stderr, CLR_RED "SQL: %s" CLR_RESET "\n", err ? err : "unknown error");
|
||||||
|
|
@ -122,7 +122,7 @@ int db_init(void) {
|
||||||
db_exec(DB, sql_seen, NULL, NULL, NULL);
|
db_exec(DB, sql_seen, NULL, NULL, NULL);
|
||||||
const char *sql_tell = "CREATE TABLE IF NOT EXISTS tell ("
|
const char *sql_tell = "CREATE TABLE IF NOT EXISTS tell ("
|
||||||
"id INTEGER PRIMARY KEY, from_nick TEXT, to_nick TEXT, "
|
"id INTEGER PRIMARY KEY, from_nick TEXT, to_nick TEXT, "
|
||||||
"message TEXT, created_at TEXT DEFAULT (datetime('now')))";
|
"message TEXT, created_at TEXT DEFAULT (datetime('now','localtime')))";
|
||||||
db_exec(DB, sql_tell, NULL, NULL, NULL);
|
db_exec(DB, sql_tell, NULL, NULL, NULL);
|
||||||
const char *sql_clear_ai = "DELETE FROM ai_pending";
|
const char *sql_clear_ai = "DELETE FROM ai_pending";
|
||||||
db_exec(DB, sql_clear_ai, NULL, NULL, NULL);
|
db_exec(DB, sql_clear_ai, NULL, NULL, NULL);
|
||||||
|
|
@ -170,9 +170,9 @@ void sqlite_cleanup(void) { if (sqlite_lib) { dlclose(sqlite_lib); sqlite_lib =
|
||||||
int db_set(const char *key, const char *value, const char *nick) {
|
int db_set(const char *key, const char *value, const char *nick) {
|
||||||
void *stmt;
|
void *stmt;
|
||||||
const char *sql = "INSERT INTO zynk(key,value,nick,updated_at)"
|
const char *sql = "INSERT INTO zynk(key,value,nick,updated_at)"
|
||||||
" VALUES(?,?,?,datetime('now'))"
|
" VALUES(?,?,?,datetime('now','localtime'))"
|
||||||
" ON CONFLICT(key) DO UPDATE SET value=excluded.value,"
|
" ON CONFLICT(key) DO UPDATE SET value=excluded.value,"
|
||||||
" nick=excluded.nick, updated_at=datetime('now')";
|
" nick=excluded.nick, updated_at=datetime('now','localtime')";
|
||||||
if (db_prepare(DB, sql, -1, &stmt, NULL) != SQLITE_OK) return -1;
|
if (db_prepare(DB, sql, -1, &stmt, NULL) != SQLITE_OK) return -1;
|
||||||
db_bind_text(stmt, 1, key, -1, SQLITE_STATIC);
|
db_bind_text(stmt, 1, key, -1, SQLITE_STATIC);
|
||||||
db_bind_text(stmt, 2, value, -1, SQLITE_STATIC);
|
db_bind_text(stmt, 2, value, -1, SQLITE_STATIC);
|
||||||
|
|
@ -287,9 +287,9 @@ void db_rotate_history(const char *prefix, const char *value) {
|
||||||
}
|
}
|
||||||
void *stmt;
|
void *stmt;
|
||||||
const char *sql = "INSERT INTO zynk(key,value,nick,updated_at)"
|
const char *sql = "INSERT INTO zynk(key,value,nick,updated_at)"
|
||||||
" VALUES(?,?,?,datetime('now'))"
|
" VALUES(?,?,?,datetime('now','localtime'))"
|
||||||
" ON CONFLICT(key) DO UPDATE SET value=excluded.value,"
|
" ON CONFLICT(key) DO UPDATE SET value=excluded.value,"
|
||||||
" nick=excluded.nick, updated_at=datetime('now')";
|
" nick=excluded.nick, updated_at=datetime('now','localtime')";
|
||||||
if (db_prepare(DB, sql, -1, &stmt, NULL) == SQLITE_OK) {
|
if (db_prepare(DB, sql, -1, &stmt, NULL) == SQLITE_OK) {
|
||||||
db_bind_text(stmt, 1, kbuf[0], -1, SQLITE_STATIC);
|
db_bind_text(stmt, 1, kbuf[0], -1, SQLITE_STATIC);
|
||||||
db_bind_text(stmt, 2, value, -1, SQLITE_STATIC);
|
db_bind_text(stmt, 2, value, -1, SQLITE_STATIC);
|
||||||
|
|
|
||||||
2
zynk.h
2
zynk.h
|
|
@ -22,7 +22,7 @@
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
#ifndef ZYNK_VERSION
|
#ifndef ZYNK_VERSION
|
||||||
#define ZYNK_VERSION "0.40.0"
|
#define ZYNK_VERSION "0.0.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VERSION ZYNK_VERSION
|
#define VERSION ZYNK_VERSION
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue