You need to sign in or sign up before continuing.×
Beta
Time Conversion: 12s and 24s
45 of 54colbydauph
Loading description...
Strings
Date Time
Regular Expressions
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
The 12-hours format for 12:XX has multiple versions worldwide. It can be
12:XX PM
or12:XX AM
. In this kata, it should be specified which one should be used.In one of the example of 12-hours format, there is a
12:59 AM
. So let's assume this kata uses12:XX AM
format. However, on one of the 12 -> 24 -> 12 tests, it gave me12:00:24PM
as the input, but expected me to return12:00:24am
as the output (when reverting back to 12).What's the logic here? It against one of the rules: Format Preservation.
Throwing a string is not a good practice at all. The normal way is to throw a
new Error()
.And sure you can just check if any error is thrown? There's no need to forcefully make one only throws a specific error unless that's clarity requirements (which you have none of them, your error requirements are nothing but
error
and they're even strings).It's a good kata, and I enjoyed tackling it. There are just a couple of things you could change to make things a littler easier to understand and debug:
As it is, the formatting and spacing is kind of an afterthought, but in actuality, this is the main part of the kata. There are other problems making it hard to parse the instructions first time, also. With just a bit of rejigging and moving stuff around, the understandability would really be helped, I think.
The
.normalize()
method, while nice, does tend to give the coder cryptic errors from time to time. If a returned value is not a string, a test should fail or error should be thrown explicitly stating that problem, rather than an unrelated error arising after the fact, leaving the coder to scratch their heads, print out the inner-workings of.normalize()
, re-read the instructions, and so-on until they figure out what's going on.Messages like "'undefined' is not a valid time" is a bit too sparse--and misleading--to be that helpful. First, you could actually say that a value was returned, and that an error was expected.
Test.expectError
is perfect for this. Second, the input value is always wrapped in'
characters, when in reality, the value is rarely a string at all. You can useTest.inspect(value)
to generate a readable string of the value in question to use in your errors or test failure messages.But again, good job on the kata so far!
Why throw 'error'? Should rather use throw new Error();
On the 24 > 12 > 24 tests, 24:XX is not a valid 24h format
Is this Issue still relevant?
The only real problem I had (except for spacing and such) was that in the 24->12->24 test phase, I got as original input '24:12:15', which isn't a valid 24-hour time. The function for generating random 24-hour times isn't visible, so I can't really check it.
Otherwise, it would have been nice with some static tests to check the edge cases. In particular around 00h and 12h.
Nice kata!
This is strangely phrased, and makes it sound like handling case and spacing flexibly is optional, which it isn't.
Also, as jacobb mentioned, you ought to include static edge cases in addition to the random tests. Otherwise, a partially wrong solution can easily pass just by getting lucky.
This comment has been hidden.