From 5fedc8a9318e5ba1dcfd582b06da8fdea2e13124 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 5 Dec 2019 11:20:46 -0500 Subject: Insert colons into timezones --- unscoop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'unscoop.c') diff --git a/unscoop.c b/unscoop.c index 7679f19..be57128 100644 --- a/unscoop.c +++ b/unscoop.c @@ -158,11 +158,15 @@ int main(int argc, char *argv[]) { "INSERT OR IGNORE INTO names (nick, user, host)" "VALUES ($nick, $user, $host);" ); + // SQLite expects a colon in the timezone, but ISO8601 does not. sqlite3_stmt *insertEvent = dbPrepare( db, SQLITE_PREPARE_PERSISTENT, "INSERT INTO events (contextID, type, time, nameID, target, message)" - "SELECT $contextID, $type, $time, id, $target, $message FROM names" - " WHERE nick = $nick AND user = $user AND host = $host;" + "SELECT" + " $contextID, $type," + " datetime(substr($time, 1, 22) || ':' || substr($time, -2))," + " id, $target, $message" + " FROM names WHERE nick = $nick AND user = $user AND host = $host;" ); dbBindInt(insertEvent, 1, contextID); @@ -194,7 +198,6 @@ int main(int argc, char *argv[]) { if (error) continue; dbBindInt(insertEvent, 2, matcher->type); - // FIXME: SQLite doesn't parse ISO8601 timezones. bindMatch(insertEvent, 3, line, match[matcher->time]); if (matcher->target) { bindMatch(insertEvent, 4, line, match[matcher->target]); -- cgit 1.4.1