made get_epoch_time function

This commit is contained in:
antares 2024-07-07 01:31:03 -07:00
parent 86d397b548
commit baa9ebc17f

View File

@ -22,7 +22,7 @@ function get(link)
return parsed return parsed
end end
function short_date(timestamp) function get_epoch_time(timestamp)
local pattern = "(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+).000Z" local pattern = "(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+).000Z"
local year, month, day, hour, min, sec = timestamp:match(pattern) local year, month, day, hour, min, sec = timestamp:match(pattern)
local epoch = os.time({ local epoch = os.time({
@ -33,7 +33,13 @@ function short_date(timestamp)
min = min, min = min,
sec = sec sec = sec
}) })
return os.date("%a, %B %d, %Y", epoch) return epoch
end
function get_short_date(timestamp)
return os.date(
"%a, %B %d, %Y", get_epoch_time(timestamp)
)
end end
function write_comments(pleroma_posts, instance) function write_comments(pleroma_posts, instance)
@ -50,7 +56,7 @@ function write_comments(pleroma_posts, instance)
local replies = pleroma_posts["descendants"] local replies = pleroma_posts["descendants"]
for _, post in ipairs(replies) do for _, post in ipairs(replies) do
local pid = post["id"] local pid = post["id"]
local datetime = short_date(post["created_at"]) local datetime = get_short_date(post["created_at"])
local uid = post["account"]["id"] local uid = post["account"]["id"]
local alias = post["account"]["acct"] local alias = post["account"]["acct"]
local text = post["pleroma"]["content"]["text/plain"] local text = post["pleroma"]["content"]["text/plain"]
@ -73,8 +79,8 @@ end
function Meta(meta) function Meta(meta)
local elem = meta["pleroma-url"] local elem = meta["pleroma-urls"]
-- print(elem) print(elem)
if elem == nil then if elem == nil then
return -- abort return -- abort
end end