about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-05-18 16:21:50 -0400
committerJune McEnroe <june@causal.agency>2021-05-18 16:25:34 -0400
commit8839b281168687bf5bfb38d64d0b27775e0a6865 (patch)
tree7f65d1ec71ccc8cf386e33f1b88cc4895f0ddbbd
parentAdd weechat format to unscoop (diff)
downloadlitterbox-8839b281168687bf5bfb38d64d0b27775e0a6865.tar.gz
litterbox-8839b281168687bf5bfb38d64d0b27775e0a6865.zip
Interpret weechat and znc timestamps as local time
-rw-r--r--unscoop.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/unscoop.c b/unscoop.c
index ac61b88..95f3315 100644
--- a/unscoop.c
+++ b/unscoop.c
@@ -271,18 +271,19 @@ static const struct Format {
 	size_t network;
 	size_t context;
 	size_t date;
+	bool local;
 } Formats[] = {
 	{
 		"generic", Generic, ARRAY_LEN(Generic),
-		"([^/]+)/([^/]+)/[^/]+$", 1, 2, 0,
+		"([^/]+)/([^/]+)/[^/]+$", 1, 2, 0, false,
 	},
 	{
 		"catgirl", Catgirl, ARRAY_LEN(Catgirl),
-		"([^/]+)/([^/]+)/[0-9-]+[.]log$", 1, 2, 0,
+		"([^/]+)/([^/]+)/[0-9-]+[.]log$", 1, 2, 0, false,
 	},
 	{
 		"irc", IRC, ARRAY_LEN(IRC),
-		"^$", 0, 0, 0,
+		"^$", 0, 0, 0, false,
 	},
 	{
 		"textual", Textual, ARRAY_LEN(Textual),
@@ -292,15 +293,15 @@ static const struct Format {
 			"([^/]+)/"
 			"[0-9-]+[.]txt$"
 		),
-		1, 4, 0,
+		1, 4, 0, false,
 	},
 	{
 		"weechat", WeeChat, ARRAY_LEN(WeeChat),
-		"irc[.](.+)[.]([^.]+)[.]weechatlog$", 1, 2, 0,
+		"irc[.](.+)[.]([^.]+)[.]weechatlog$", 1, 2, 0, true,
 	},
 	{
 		"znc", ZNC, ARRAY_LEN(ZNC),
-		"([^/]+)/(moddata/log/)?([^/]+)/([0-9-]+)[.]log$", 1, 3, 4,
+		"([^/]+)/(moddata/log/)?([^/]+)/([0-9-]+)[.]log$", 1, 3, 4, true,
 	},
 };
 
@@ -353,6 +354,8 @@ static void prepareInsert(void) {
 			CASE
 			WHEN :time LIKE '%+____' OR :time LIKE '%-____' THEN
 				strftime('%s', substr(:time, 1, 22) || ':' || substr(:time, -2))
+			WHEN :local THEN
+				strftime('%s', coalesce(:date || ' ', "") || :time, 'utc')
 			ELSE
 				strftime('%s', coalesce(:date || ' ', "") || :time)
 			END,
@@ -384,6 +387,7 @@ matchLine(const struct Format *format, const regex_t *regex, const char *line) {
 			}
 		}
 
+		dbBindInt(insertEvent, ":local", format->local);
 		dbBindInt(insertEvent, ":type", matcher->type);
 		for (size_t i = 0; i < ARRAY_LEN(matcher->params); ++i) {
 			const char *param = matcher->params[i];