12
3
The challenge is simplistic, given an input time as a string in any one of the following formats:
hh
, hh:mm
or hh:mm:ss
with 0 ≤ hh ≤ 23
, 0 ≤ mm ≤ 59
and 0 ≤ ss ≤ 59
.
Output what time it currently is using the following symbols:
AA LABEL FOR CHARACTER CODE POINT HEXADECIMAL
== ==================== ========== ===========
Clock Face 01 Oclock 128336 0x1F550
Clock Face 02 Oclock 128337 0x1F551
Clock Face 03 Oclock 128338 0x1F552
Clock Face 04 Oclock 128339 0x1F553
Clock Face 05 Oclock 128340 0x1F554
Clock Face 06 Oclock 128341 0x1F555
Clock Face 07 Oclock 128342 0x1F556
Clock Face 08 Oclock 128343 0x1F557
Clock Face 09 Oclock 128344 0x1F558
Clock Face 10 Oclock 128345 0x1F559
Clock Face 11 Oclock 128346 0x1F55A
Clock Face 12 Oclock 128347 0x1F55B
In the following format:
It is currently {Clock Face 1} with {mm} minutes and {ss} seconds until {Clock Face 2}.
Examples (Including all fringe cases):
Case with only hours...
f("12") = "It is currently ."
Case with hours and minutes...
f("12:30") = "It is currently with 30 minutes until ."
Case with only hours, but has minutes included as 00...
f("12:00") = "It is currently ."
Case with hours, minutes and seconds...
f("12:30:30") = "It is currently with 29 minutes and 30 seconds until ."
Case with hours and minutes, but has seconds included as 00...
f("12:30:00") = "It is currently with 30 minutes until ."
Case with hours and minutes, with less than a minute until the next hour...
f("12:59:59") = "It is currently with 1 seconds until ."
You do not have to change from plural to singular.
Case with hours and minutes, with 1 minute to the next hour...
f("12:59") = "It is currently with 1 minutes until ."
You do not have to change from plural to singular.
Case using military time (yes you must handle this)...
f("23:30:30") = "It is currently with 29 minutes and 30 seconds until ."
Invalid cases...
f("PPCG") = This cannot occur, you are guaranteed a valid format by the definition of the problem.
f(66:66:66) = This cannot occur, you are guaranteed valid numbers by the definition of the problem.
f(24:60:60) = This cannot occur, you are guaranteed valid numbers by the definition of the problem.
You do not have to conform to any style of output for invalid cases, errors are fine.
Overall the challenge is rather simplistic, but seemed to be dynamic enough to be fun in my opinion. The shortest code here is the winner as there isn't much variable aspect to the code other than length.
1Closely related. – Martin Ender – 2016-12-27T17:21:34.690
Should this be a whole program or is a function/lambda enough? – devRicher – 2016-12-27T17:50:12.407
2I think that instead of
0 < hh < 24
,0 < mm < 60
and0 < ss < 60
, you meant0 ≤ hh ≤ 23
,0 ≤ mm ≤ 59
and0 ≤ ss ≤ 59
. – Erik the Outgolfer – 2016-12-27T18:02:08.177Assume UTF-8, do the clock emojis count full byte count, or none, or one byte? – devRicher – 2016-12-27T18:16:32.813
@devRicher http://meta.codegolf.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet?answertab=votes#tab-top also, use byte counting utilities like http://bytesizematters.com/ to determine the answer to the second question. The clock, if used directly in your code, counts for 4 bytes.
– Magic Octopus Urn – 2016-12-27T18:19:28.7972Is a language specific Date/DateTime struct allowed as input? – devRicher – 2016-12-27T18:35:03.137
@devRicher No, the input is a string, exactly as described. – Magic Octopus Urn – 2016-12-27T18:43:26.970
Why do we have to support military time? It doesn't add much to the challenge. – Rɪᴋᴇʀ – 2016-12-27T19:27:43.513
@EasterlyIrk
hh%12
isn't hard to support either. – Magic Octopus Urn – 2016-12-27T19:32:13.763@JamesHolderness updated with answers, if the quantity of the time is 0, you drop it. You do not have to change plural versions to singular versions. – Magic Octopus Urn – 2016-12-27T20:11:03.730
Case
12:00:01
should bewith 59 minutes and 59 seconds until
... Correct? – edc65 – 2016-12-27T20:21:52.1102@carcusocomputing You specify that the code must handle 24 hour time, does the code have to handle
AM
orPM
tags? – Taylor Scott – 2016-12-27T20:39:56.157If the language only supports UCS-2, would it be OK to output the 2 characters that would produce the clock symbol if they were UTF-16? – 12Me21 – 2017-01-27T20:33:30.487
@12Me21 if it's a limitation of the language you may, but that limitation must be explained in depth. – Magic Octopus Urn – 2017-01-27T20:36:44.133
May we, if need be, take the input as a string in brackets (
[HH:MM:SS]
) rather than in double quotes ("HH:MM:SS"
)? – R. Kap – 2017-01-29T10:07:03.250@R.Kap yeah sure. – Magic Octopus Urn – 2017-01-30T13:43:09.767