Files
metabuilder/packages/irc_webchat/seed/scripts/format_time.lua
2025-12-30 12:36:03 +00:00

23 lines
494 B
Lua

---@param timestamp number Unix timestamp in milliseconds
---@return string Formatted time string in HH:MM AM/PM format
local function formatTime(timestamp)
local date = os.date("*t", timestamp / 1000)
local hour = date.hour
local ampm = "AM"
if hour >= 12 then
ampm = "PM"
if hour > 12 then
hour = hour - 12
end
end
if hour == 0 then
hour = 12
end
return string.format("%02d:%02d %s", hour, date.min, ampm)
end
return formatTime