nvim: implement the rest of date/time snippets

This commit is contained in:
dogeystamp 2024-04-03 14:36:16 -04:00
parent e327fb4f3e
commit c5a061a49a
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38

View File

@ -1,5 +1,28 @@
return {
s({ trig = "today", desc = "YYYY-MM-DD date of today" }, f(function ()
--------------------------------
--------------------------------
-- date and timekeeping snippets
--------------------------------
--------------------------------
s({ trig = "today", desc = "YYYY-MM-DD date of today" }, f(function()
return os.date("%Y-%m-%d")
end))
end)),
s({ trig = "yesterday", desc = "YYYY-MM-DD date of yesterday" }, f(function()
local t = os.date("*t")
return os.date("%Y-%m-%d", os.time { year = t.year, month = t.month, day = t.day - 1 })
end)),
s({ trig = "timestamp", desc = "Unix day timestamp (locked to midnight)" }, f(function()
local t = os.date("*t")
return tostring(os.time { year = t.year, month = t.month, day = t.day, hour = 0 })
end)),
s(
{
trig = "datestamp (%d-)-(%d-)-(%d-)",
regTrig = true,
desc =
"YYYY-MM-DD to Unix day timestamp (locked to midnight)"
}, f(function(_, snip)
return tostring(os.time { year = snip.captures[1], month = snip.captures[2], day = snip.captures[3], hour = 0 })
end)),
}