1. Ok. I REALLY hope this is the right place for this.

I made a li'l script that turns a minute value into a time of day on a 12 hour clock.

```function ToHoursMinutes(time)
local ampm = "AM"
local time = tonumber(time)
if time >= 1440 then --Don't do more than 1440
time = time - 1440
end
time = time/60 --60 minutes in an hour.
local hours, minutes = math.modf(time) --Split hours from minutes
if hours >= 12 then
ampm = "PM"
end
if hours > 12 then
hours = hours - 12
end
if hours == 0 then
hours = 12
end
if minutes == nil then --Errors b-gone!
minutes = 0
end
minutes = math.Round(minutes * 60) --Turn raw minutes into actual minutes.
if minutes < 10 then
minutes = "0"..tostring(minutes) -- 7:07 instead of 7:7
end
local time = tostring(hours)..":"..tostring(minutes) --Colon. Combine hours & minutes.
return time, ampm
end```

The input is any number. Probably below 1440, since that's the amount of minutes in a day. It pumps out two outputs: The time and AM or PM. Here's an example of its use:

```local CurTimeBox = vgui.Create("DFrame")
CurTimeBox:SetPos(ScrW()/2, ScrH()/2)
CurTimeBox:SetSize(500, 500)
CurTimeBox:MakePopup()

local Time = vgui.Create("DLabel")
Time:SetParent(CurTimeBox)
Time:Center()
local newtime = 1
function Time:Think()
local time, ampm = ToHoursMinutes(newtime)
newtime = newtime + 1
self:SetText(time.." "..ampm)
self:SizeToContents()
self:Center()
end
Time:SetFont("HUDNumber")
Time:SizeToContents()
Time:SetTextColor(Color(255, 255, 255, 255))
```

So you can copy/paste this into your script if you want. I don't need credit or anything.

Again, sorry if this is in the wrong spot. I actually DID read the sticky.
Friendly x 1 (list)

2. Have you tried using fmod to optimize your code?

3. Have you tried using fmod to optimize your code?
Nope. :P
What's that?

Dumb x 3 (list)

I Agree, Google Is The Database Of This Planet Itself.
If you want the answer to it, ask the forum AFTER googling it.
Dumb x 5 (list)

6. Have you tried using fmod to optimize your code?
Oh that.

Okay. Let me just rewrite the whole damn thing. :P

7. ```if minutes == nil then --Errors b-gone!
minutes = 0
end
```

Can be made into this for optimization:

```minutes = minutes or 0
```
Agree x 3 Dumb x 1 (list)

8. ```if minutes == nil then --Errors b-gone!
minutes = 0
end
```

Can be made into this for optimization:

```minutes = minutes or 0
```
Wrong, this is actually slower, the correct optimization would be

if not minutes then minutes = 0 end
Agree x 3 Disagree x 1 (list)

9. Wrong, this is actually slower, the correct optimization would be

if not minutes then minutes = 0 end
Just curious, is it a significant amount slower or is it one of those things where it could even be in a Think hook and still not really make a difference? I often times use 'or' / 'and' to make a ghetto ternary statement in some of my paint hooks mainly just because I like how it looks. If it is significantly slower than it looks like I'll be changing them all back to if-else statements

10. Just curious, is it a significant amount slower or is it one of those things where it could even be in a Think hook and still not really make a difference? I often times use 'or' / 'and' to make a ghetto ternary statement in some of my paint hooks mainly just because I like how it looks. If it is significantly slower than it looks like I'll be changing them all back to if-else statements
When I tested it a nil compare was up to 5% faster in 90% of the checks.

While the not check was about 20% faster in ALL cases.

So, it's not significant but he's wrong still.

11. What type of tests are you doing?

http://trac.caspring.org/wiki/LuaPerformance

Test #5.

12. What type of tests are you doing?

http://trac.caspring.org/wiki/LuaPerformance

Test #5.
Did runtime checks, using SysTime() delta's.