diff options
-rwxr-xr-x | generate-index.lua | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/generate-index.lua b/generate-index.lua index 65f7e14..6022c31 100755 --- a/generate-index.lua +++ b/generate-index.lua @@ -2,34 +2,24 @@ local pretty = require"pl.pretty" local dir = require"pl.dir" local gumbo = require"gumbo" -local months = { - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", -} local function parse (stamp) - local year, month, day = stamp:match"(%d+)-(%d?%d)-(%d?%d)T?" - year, month, day = tonumber(year), tonumber(month), tonumber(day) - if not year or not month or not day then - return nil - end - return {year=year, month=month, day=day} + local year, month, day, hour, min, sec = stamp:match"(%d+)-(%d?%d)-(%d?%d)T(%d?%d):(%d?%d):(%d?%d)" + return { + year = tonumber(year), + month = tonumber(month), + day = tonumber(day), + hour = tonumber(hour), + min = tonumber(min), + sec = tonumber(sec), + } end local function describe (date) - return string.format("%d %s", date.day, months[date.month]) + -- strftime(3) still does not support printing day of month without leading zero or space. + return string.format("%d %s", date.day, os.date("%B", os.time(date))) end |