clix/archive.lua

changeset 159
68e09745d928
parent 148
27a9f28724d3
child 161
64cb732f67e4
equal deleted inserted replaced
158:703fa6922493 159:68e09745d928
1 local jid_split = require"util.jid".split; 1 local jid_split = require"util.jid".split;
2 local bare_jid = require"util.jid".bare; 2 local bare_jid = require"util.jid".bare;
3 local parse_datetime = require"util.datetime".parse; 3 local datetime = require"util.datetime";
4 return function (opts, arg) 4 return function (opts, arg)
5 if opts.short_help then 5 if opts.short_help then
6 print("Fetch archived messages"); 6 print("Fetch archived messages");
7 return; 7 return;
8 end 8 end
9 9
10 local function parse_datetime(s)
11 if s:match("^%d%d:") then
12 s = datetime.date().."T"..s;
13 end
14 if #s < 20 then
15 s = s .. ("0000-01-01T00:00:00Z"):sub(#s+1)
16 end
17 return datetime.parse(s)
18 end
10 local reverse = opts.before; 19 local reverse = opts.before;
11 if opts.start then 20 if opts.start then
12 opts.start = parse_datetime(opts.start); 21 opts.start = parse_datetime(opts.start);
13 end 22 end
14 if opts["end"] then 23 if opts["end"] then

mercurial