2 |
2 |
3 local ndp = require "ndp"; |
3 local ndp = require "ndp"; |
4 |
4 |
5 local base; |
5 local base; |
6 for line in io.lines() do |
6 for line in io.lines() do |
7 if line:match("^base:%d+$") then |
7 if line:match("^base:") then |
|
8 -- Set the unixtime to calculate relative to, eg. base:0 |
8 base = tonumber(line:match("^base:(%d+)$")); |
9 base = tonumber(line:match("^base:(%d+)$")); |
9 else |
10 else |
10 local ret = ndp.when(line, base); |
11 local ret, start, finish = ndp.when(line, base); |
11 print(os.date("%c", ret).." ("..ret..")"); |
12 local remaining = ""; |
|
13 if start and finish then |
|
14 remaining = (line:sub(1, start)..line:sub(finish, -1)):gsub("^[%s%p]+", ""):gsub("[%s%p]+$", ""); |
|
15 end |
|
16 print(os.date("%c", ret).." ("..ret..")"..((#remaining>0 and (": "..remaining)) or "")); |
12 end |
17 end |
13 end |
18 end |
14 |
19 |