You’re using the wrong format specifier, %s is for strings, and you could do the formatting in a single statement:
local function formatAsDigital(input)
local hours = math.floor(input/60);
return string.format("%d:%02d %s", hours%12, input%60, hours >= 12
and "pm" or "am");
end
The above reply explains the format specifier well, but it can be any digit
string.format("%05d", 9) for example, would result in 00009, since 9 isn’t 5 digits, so the first 4 are just a “placeholder”
Not sure how you want it, but how this works is it treats the argument received as minutes, so if you pass 60, you get "1:00" in return. If that’s not what you want lmk and i’ll make the changes necessary
Huh ok, what would input be? Just the time of day??
EDIT Nvm, that didn’t work, had this:
local function getTime(setTime)
local hours = math.floor(setTime/60)
return string.format("%d:%02d %s", hours%12, setTime%60, hours > 12 and "pm" or "am")
end
local StartTime, EndTime = getTime(JobInfo.StartTime), getTime(JobInfo.EndTime)
Time.Text = StartTime .. ' - ' .. EndTime
input is treated as minutes (can also be seconds, since it works exactly the same, just gotta multiply or divide) and what is JobInfo.StartTime and EndTime?
My function takes a number, your original function took a string, judging from the use of string.sub