I'm writing a program to convert UTC (eg 2359) to a timezone (egg UTC+930)
For most cases it works using my formula (utc + utc-offset % 2400)
So for 7am + 9 hours: (700 + 900) % 2400 which evaluates to 1600 (4PM) and is correct
This does not work if it is something like 23:59 + 9 hours 45 minutes:
(2359 + 945) % 2400 = 904...which is wrong.
There are $60$ minutes in an hour, not $100$, so you can't treat the time 23:59 as being the same as the number $2359$.
Add the minutes together first, then carry over an hour if necessary.
For example, $59$ minutes $+$ $45$ minutes $=$ $104$ minutes $=$ $1$ hour and $44$ minutes.
So 23:59 $+$ 9:45 = $23 + 9 + 1$ hours and $44$ minutes.
Modulo $24$ hours, this is $9$ hours and $44$ minutes.