mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 14:25:02 +00:00
23 lines
494 B
Lua
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
|