It's time for a clock challenge!
TI-Basic, 94 bytes
"
Repeat 99<length(Ans
Ans+"-
End
Ans→Str1
Repeat 0
getTime
ClrDraw
Ans{Ans(1)≠24,1,1
Text(0,0,Ans(1),sub(Str1,1,1+Ans(2
Text(6,0,Ans(1)+1,sub(Str1,1,61-Ans(2
End
Relatively straightforward. That's a string with one space at the beginning. The hours are right-aligned. This only works on TI-84+ calculators since the TI-83 does not have an internal clock.
Edit: Thanks @kundor for noticing that I didn't close the last loop. Fixed now (+2 bytes).
Edit #2: First hour should be zero, not twenty-four. Corrected at a cost of +14 bytes.
Batch, 197 bytes
@echo off
set/ah=100+%time:~0,2%,m=1%time:~3,2%
cls
call:l
set/ah=(h-3)%%24+100,m=260-m
call:l
timeout/t>nul 60
%0
:l
set s=%h:~1%
for /l %%i in (101,1,%m%)do call set s=%%s%%-
echo %s%
Note: 10th line has a trailing space. For me, %time%
formats hours with a leading space but minutes with a leading zero. I decided a leading zero was an easier output format, since all I have to do for that is to add 100 hours and remove the first digit. Minutes are trickier as 08
or 09
will cause octal parse errors, so I prefix a 1
effectively adding 100 minutes, adjusting for this by offsetting the loop appropriately, which is a byte shorter than subtracting the 100.
Python 3.6, 110 114 112 bytes
from time import*
while[sleep(9)]:h,m=localtime()[3:5];print('\n'*50+'%2d '%h+'-'*m+f'\n{-~h%24:2} '+'-'*(60-m))
This uses the new f-string formatting to save one byte (f'\n{h+1:2} '
vs '\n%2d '%(h+1)
.) You can change [sleep(9)]
to 1
to save 8 bytes, but then it just spams the screen.
Saved one byte changing while 1:...;sleep 60
to while[sleep(60)]:...
, thanks to TuukkaX.
I had to use 5 more bytes to get the next hour displayed after 23 to be 0, instead of 24, as OP just commented. :-(
Recovered one byte by only sleeping 9 seconds instead of 60.
Saved two bytes using a bit-fiddling to shorten (h+1)%24
, borrowed from Value Ink's Ruby answer.