From 23d6b34917de71a2c54aff0e85f3a24a59cec69b Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 29 Aug 2024 00:27:06 +0200 Subject: Use strftime/os.date to get month name --- generate-index.lua | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'generate-index.lua') 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 -- cgit v1.1