Since I saw the first one a few years ago, I always was subjugated by this kind of word clock where the time is actually spelled out by words being lit up or not into a meaningful sentence.
The text displayed on that clock is the following.
IT IS HALF TEN
QUARTER TWENTY
FIVE MINUTES TO
PAST TWO THREE
ONE FOUR FIVE
SIX SEVEN EIGHT
NINE TEN ELEVEN
TWELVE O'CLOCK
Your task is to write such a working clock. Words are lit up if and only if they're relevant to printing the current time. Otherwise, they're lit down. Words are "lit up" by being printed and are "lit down" by being replaced by a number of spaces being the length of the word.
Example: if the current time is 17:23, the printed text must be exactly the following:
IT IS
TWENTY
FIVE MINUTES
PAST
FIVE
Rules
- The time printed is the 12h variant, but without AM/PM.
- The rounding is done on the base of minutes only (seconds are totally irrelevant). The rounding is done to the closest multiple of 5. So, for example, even though 17:52:38 really is closest to 17:55, but since the seconds are irrelevant, 17:52 is actually rounded down to 17:50, and the text printed is "IT IS TEN MINUTES TO SIX" (with relevant spacing). So if
XX
is a multiple of five,XX
will be used from HH:(XX-2):00 until HH:(XX+2):59. The wordMINUTES
must appear ifFIVE
,TEN
orTWENTY
are lit up in the minutes section (before "TO" or "PAST"). - All irrelevant words are replaced by as many spaces as needed to keep the text where it is located in the template above. Trailing spaces may be trimmed. Spaces relevant to keeping the text at the expected position must be kept.
Trailing lines may be trimmed as well. Relevant empty lines are still required to appear. Example:
IT IS TEN MINUTES PAST TWO
Do not light up
TEN
on the first line orFIVE
on the third line when these values refer to the hours.- You may accept an input. If you accept an input, the input will be the time to print in any valid format you want (string, list of integers, native time type your language support, ...), but no parameters are allowed if they're not related to the time to print. If you support no input, then you must use the current time. If you support both, that's better but there's no bonus ;)
- Your code may be a program, a function, a lambda but not snippet.
- If your language supports printing in any way, it must print the result (in a file, on the standard output, I don't mind). If your language doesn't support printing in any way, it is allowed to simply "return" the expected text. The result may be either all uppercase or all lowercase, not a mix of both.
- Standard loopholes apply.
- This is code-golf so the shortest code wins!
- In the measure of possible, please provide a link to an online interpreter of your language.
Test cases
Input: <no input> (the current local time is 19:20)
Output:
IT IS
TWENTY
MINUTES
PAST
SEVEN
Input: 13:15
Output: (empty line is being printed)
IT IS
QUARTER
PAST
ONE
Input: 13:58
Output: (rounding)
IT IS
TWO
O'CLOCK
Input: 14:30
Output: (half is always a edge-case)
IT IS HALF
PAST TWO
Input: 15:35
Output: (light up "TO")
IT IS
TWENTY
FIVE MINUTES TO
FOUR
Input: 10:00
Output: (do not use the TEN or FIVE on the first line when referring to the hours)
IT IS
TEN
O'CLOCK
Input: 12:00
Output: (O'CLOCK and a lot of empty lines)
IT IS
TWELVE O'CLOCK
NinEighTen
orTwOnEleven
to save space - that would have made the challenge extra hard!) \$\endgroup\$