Implement a Simple Stopwatch
Operation Flashpoint scripting language, 174 171 bytes
s=""
#l
t=_time
t=t-t%1
a=t%60
c=(t-a)/60
b=c%60
c=(c-b)/60
d=""
e=d
f=d
?a<10:d=0
?b<10:e=0
?c<10:f=0
s=s+format["%1%2:%3%4:%5%6\n",f,c,e,b,d,a]
hint s
@t+1<_time
goto"l"
In action:
158 bytes, if the previous time is overwritten by the next time:
#l
t=_time
t=t-t%1
a=t%60
c=(t-a)/60
b=c%60
c=(c-b)/60
d=""
e=d
f=d
?a<10:d=0
?b<10:e=0
?c<10:f=0
hint format["%1%2:%3%4:%5%6",f,c,e,b,d,a]
@t+1<_time
goto"l"
Technically, no carriage return is used, so I'm not sure if this version confines to the rules.
Bash + coreutils, 28 26 bytes
date -s0|yes date +c%T|sh
The unprintable character between +
and %
is an ESC byte.
This sets the system time to 00:00:00 and thus requires root privileges. It also assumes that the timezone is UTC and that no other processes will interfere with the system clock.
Each new timing resets the terminal, thus overwriting the previous one.
Bash + coreutils, 38 29 bytes
date -s0|yes date +%T|sh|uniq
The same restrictions as before apply. Each new timing is shown on a new line.
MATL, 17 16 bytes
`Z`12L/13XOD1Y.T
Try it at MATL Online!
How it works
` % Do...while loop
Z` % Push seconds elapsed since start of program
12L % Push 86400 (predefined literal)
/ % Divide. This transforms seconds into days
13XO % Convert to date string with format 13, which is 'HH:MM:SS'
D % Display
1Y. % Pause for 1 second
T % True. Used as loop condition for infinite loop
% End loop (implicit)