| 1 | #!/usr/bin/env lua |
| 2 | |
| 3 | local ndp = require "ndp"; |
| 4 | |
| 5 | local base; |
| 6 | for line in io.lines() do |
| 7 | if line:match("^base:") then |
| 8 | -- Set the unixtime to calculate relative to, eg. base:0 |
| 9 | base = tonumber(line:match("^base:(%d+)$")); |
| 10 | else |
| 11 | local ret, start, finish = ndp.when(line, base); |
| 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 "").." ["..(start or "?")..","..(finish or "?").."]"); |
| 17 | end |
| 18 | end |