Software /
code /
clix
Changeset
159:68e09745d928
clix.archive: Handle partial timestamps (e.g. hh:mm or yyyy-mm-dd)
Nicer than typing entire XEP-0082 timestamps
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 06 Nov 2021 16:25:50 +0100 |
parents | 158:703fa6922493 |
children | 160:6c1953fbe0fa |
files | clix/archive.lua |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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);