summaryrefslogtreecommitdiff
path: root/generate-index.lua
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-08-29 00:27:06 +0200
committerAki <please@ignore.pl>2024-08-29 00:27:06 +0200
commit23d6b34917de71a2c54aff0e85f3a24a59cec69b (patch)
tree1e1dac76caa6cd5feafba5c5317fc1c3fb7c370c /generate-index.lua
parent56cea0dde53544380c8eb48357000b9a272ffbb1 (diff)
downloadhuh-23d6b34917de71a2c54aff0e85f3a24a59cec69b.zip
huh-23d6b34917de71a2c54aff0e85f3a24a59cec69b.tar.gz
huh-23d6b34917de71a2c54aff0e85f3a24a59cec69b.tar.bz2
Use strftime/os.date to get month name
Diffstat (limited to 'generate-index.lua')
-rwxr-xr-xgenerate-index.lua32
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