mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-06 11:39:36 +00:00
24 lines
420 B
Lua
24 lines
420 B
Lua
-- Format Timestamp
|
|
-- Formats a timestamp for display in 12-hour format
|
|
|
|
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
|