25
4
I'd like you to build me a clock that displays time in this format:
18 ----------
19 --------------------------------------------------
This displays '18:10'. The current hour and the next hour are shown at the front of the line, followed by a space and a number of dashes: on the first line the number of minutes that have passed in this hour, and the second line shows how many more minutes to go in this hour.
To clarify
- The clock should display the system's time. If fetching the time from another source is more convenient, that's fine too. It may not be supplied as input.
- At
18:00
, the top line is just18
(Trailing spaces allowed but not required) - At
18:59
, the bottom line is19 -
- The hours < 10 are either pre-padded with a
0
(01 -----
) or right-aligned (1 -----
). A left-aligned single digit is not allowed, not even if the dashes start at the right place (1 -----
is invalid). - The clock should display the hours in a 24h-format.
- Although it's called the 24h format, there is not actually a
24
on it. During the 23rd hour, the second line starts with00
or0
. - The display needs to be updated at least once a minute, but that doesn't have to happen at exactly
00
seconds. You may update more frequently / continuously if that is more convenient, but the result must of course still be legible - not one smear all over the screen.
Input
None.
Output
- As described above. Trailing spaces to pad the clock to 60-ish positions is allowed on both lines, a trailing newline is also allowed.
- The screen needs to be cleared when displaying the next minute: either with a clear-screen command or by adding no less than 30 newlines.
Additional rules
- Standard loopholes are forbidden
- code-golf, shortest answer in bytes wins.
may we have two spaces between the number and the dashes? – Adám – 2017-01-17T16:48:59.157
@Adám I think not, see the last example in "To clarify" bullet #4. But this may not address your question, which is more general. – Timtech – 2017-01-17T16:49:43.493
6"updated once a minute" -- Can it be updated more often? – smls – 2017-01-17T16:49:59.050
1@smls Yes, you may update as often as you like. I'll change the specs to 'at least once a minute'. – steenbergh – 2017-01-17T17:52:17.513
@Adám No, only one space between the numbers and he dashes. – steenbergh – 2017-01-17T17:52:48.793
Does it have to print immediately or can it print after a minute? – George Reith – 2017-01-17T18:51:24.967
Just to clarify, is it okay for numbers less than 10 to be outputted like this
1 -----
without a leading space? – user41805 – 2017-01-17T18:52:46.8101@KritixiLithos That would break alignment with two-digit hours (9, 10 or 23, 00), so no, not allowed. – steenbergh – 2017-01-17T19:04:29.820
Can I have a leading space on all lines (and two leading spaces for single digits)? It would save about a gajillion bytes in QBasic. – DLosc – 2017-01-17T19:31:23.947
Actually, it may not be a gajillion--looks like
PRINT USING
can be used to avoid the leading space for positive numbers. TIL. But thanks. :) – DLosc – 2017-01-17T19:49:09.9001After 23, is the next hour 24 or 0? – user41805 – 2017-01-18T15:43:40.957
@KritixiLithos It's 0. – steenbergh – 2017-01-18T15:52:25.717
@steenbergh: You might want to clarify that in the question, since practically every submission has 24. – Nick Matteo – 2017-01-18T16:13:24.333
@kundor Added your suggestion. – steenbergh – 2017-01-18T16:25:32.707