24hr Clock Subroutine

So, I wrote this routine to update the time. You can pass the minutes as parameter or just use to update the timestamp.

startup.txt
-----------

*create implicit_control_flow false

*create mins 0
*create hours 0
*create days 0
*create timestamp_12 ""
*create timestamp_24 ""

Then, in its own file:

time_utils.txt
--------------

*label clock_update
*set  implicit_control_flow true
*comment UPDATE TIME
*temp add_min 0
*params
*if (param_count = 1)
	*set add_min param[1]
*set mins +add_min
*if mins >= 60
	*set mins -60
	*set hours +1
*if hours >= 24
	*set hours -24
	*set days +1

*comment UPDATE TIMESTAMP
*set timestamp_12 ""
*set timestamp_24 ""
*if (hours < 10)
	*set timestamp_12 "0"&hours
	*set timestamp_24 "0"&hours
*else
	*set timestamp_12 hours
	*set timestamp_24 hours

*if (mins < 10)
	*set timestamp_12 &(":0"&mins)
	*set timestamp_24 &(":0"&mins)
*else
	*set timestamp_12 &(":"&mins)
	*set timestamp_24 &(":"&mins)

*set implicit_control_flow false
*return

You could use the routine to update the time (always in minutes). This would update 1 hour:

*gosub_scene time_utils clock_update 60

Or you could use it only to update the timestamps.

*gosub_scene time_utils clock_update

Then you can use the timestamps variables whenever you need, with an option for 24 hours and another one for 12 hours. So:

${timestamp_12} @{(hours < 12) a.m.|p.m.}
*line_break
${timestamp_24}h

Would print, for example:

01:35 p.m.
13:35h