Julia 0.6, 7575 68 bytes
for h=0:23,m=0:59,s=0:59;@printf "%02i:%02i:%02i
" h m s;sleep(1)end
With sleep(1) allowed, simple nested for-loops are shorter than using Julias built-in time handling methods.
Old solution without sleep(1) using DateTime
t=now()-DateTime(0);Timer(x->println(Dates.format(now()-t,"HH:MM:SS")),0,1)
t
is the amount of time passed from 'day 0' to when the program is started.
now()-t
is a moment in time, which is then formatted using Dates.format()
.
t0=now(); ...; now()-t0
would yield a time difference, that cannot be used with Dates.format()
.
The timing itself is trivial with the build-in Timer
.