# HG changeset patch # User Kim Alvefur # Date 1636212350 -3600 # Node ID 68e09745d92872bca386e5e9ab5f9d4336cd0cd8 # Parent 703fa6922493b3d9e1e501c1a1adb54e575b07c9 clix.archive: Handle partial timestamps (e.g. hh:mm or yyyy-mm-dd) Nicer than typing entire XEP-0082 timestamps diff -r 703fa6922493 -r 68e09745d928 clix/archive.lua --- a/clix/archive.lua Wed Jul 14 17:00:47 2021 +0200 +++ b/clix/archive.lua Sat Nov 06 16:25:50 2021 +0100 @@ -1,12 +1,21 @@ local jid_split = require"util.jid".split; local bare_jid = require"util.jid".bare; -local parse_datetime = require"util.datetime".parse; +local datetime = require"util.datetime"; return function (opts, arg) if opts.short_help then print("Fetch archived messages"); return; end + local function parse_datetime(s) + if s:match("^%d%d:") then + s = datetime.date().."T"..s; + end + if #s < 20 then + s = s .. ("0000-01-01T00:00:00Z"):sub(#s+1) + end + return datetime.parse(s) + end local reverse = opts.before; if opts.start then opts.start = parse_datetime(opts.start);