I have a simple task that should be relatively easy to implement by means of code. Your goal is to write a program that will output the time written in Spanish, given the time in HH:MM format. Many people likely don't know how to do this, so I will elaborate.
Time in Spanish is fairly logical. It usually follows the pattern of "Es la/Son las (hour) y (minutes)." Hours are in a 12-hour format, and "Es la" is only used if the hour is 1 (i.e. one o'clock). The minutes are a different story. If the minute is less than 30, then it is represented as shown above. If the minute is over 30, however, then the hour is rounded up and the minute is subtracted. For example, 7:35 is translated to the equivalent of "8 hours minus 25 minutes." Some more examples will be given below. The list of Spanish numbers that are necessary can be found here. There are accents on some numbers, but these are not necessary.
Note: The source says "uno," but to be grammatically correct it should be "una." This shouldn't affect any answers so far.
Note 2: Also, "cero" is not necessary. If your program outputs "Es la una" or "Son las tres," that is fine with me. Sorry for these rule changes.
Rules
- Input will be provided through STDIN or the equivalent in your language.
- No reading from outside libraries.
- Your code can do anything with invalid input.
Bonuses
- -10 if your code adds these extra phrases - "y cuarto" for :15, "y media" for :30, and "menos cuarto" for :45 (rounded up).
- -15 if your code can handle A.M. and P.M., responding with "de la mañana" and "de la tarde," accordingly.
- -15 if your code can translate the current time if no input is provided.
Scoring
- This is a code-golf challenge, and it will be scored by bytes, not characters.
Examples
Input: 8:10
Output: Son las ocho y diez.
Input: 6:45
Output: Son las siete menos quince (or cuarto).
Input: 1:29
Output: Es la una y veintinueve.
Input: 12:55
Output: Es la una menos cinco.
Let me know if there is anything to specify here. This is my first question, so it is definitely not perfect.
Es la una y cero
is pretty repetitive, so I see your point. I didn't specify this, so I guess either one would be fine. Thanks for the feedback. \$\endgroup\$01:21
as a test case, because at least one answerer was confused by what you said about una vs uno. \$\endgroup\$