*><>, 43 42 bytes
<v":1200----"
S>@5dov>~r@@}r5
1&}o:&<^!?:-
Try it here!
I feel like I should be able to make this shorter, I have a couple ideas to try ... Basically this makes a stack of :1200----
. It isolates the :
and flips the stack, inserting the :
in the middle of either ----
or 1200
(depending on whichever is at the end of the stack).
I should also note that the only *><> instruction this uses is S
(sleep), otherwise this is a proper ><> program.
Update: Saved 1 byte by shifting the :
to the right instead of protecting it with a register.
Explanation
Initialisation
<v":1200----"
Here we build the stack we'll be using for the life of the program.
< move the IP left
":1200----" push ":1200----" to the stack
v move the IP down into "output time"
Output time
>@5dov
1&}o:&<^!?:-
This is the section where the time is actually outputted. First 5 is pushed to the stack so the loop below knows to run 5 times.
Initialisation:
>@5dov
> move the IP right
@ move the ":" back two spaces in the stack
5 push 5 to the stack (let's call this `i`)
do output carriage return
v move IP down into "loop"
Loop:
1&}o:&<^!?:-
< move the IP left
& place i onto the register
}o: output a character and shift the stack left
& place i back onto the stack
1 - decrement i by 1
^!?: if i == 0, exit to "recover and swap"
Recover and swap
S >~r@@}r5
Here we recover the :
from the position it results in after the output, and we end up with a reversed stack. This actually exits into "output time" nicely, causing an infinite loop.
> move the IP right
~ remove trailing i from stack
r@@ reverse the stack and move ":" to the front
}r reverse the stack again, keeping ":" on the front
S 5 sleep for 500ms
45 byte solution
<v[5"12:00"1
d/S5
o/!?l
v>]?v
00.>0"--:--"5[
Try it here!
This one is also basically a ><> program.
I really thought it'd be able to save some bytes with this approach. This quite simply outputs 12:00
, then --:--
. I save bytes by reusing the output routine o/!?l
(I even reuse that mirror as both entry and exit). I utilise multiple stacks to store the state (has output 12
or --
), and select which state I should output with v>]?v
.
Explanations coming soon! (1/2)