I’m still stuck on the Timestamp microservice project. I’ve spent a week re-writing my code and I’ve tried using the debugger in Chrome.
Not sure why it won’t work, since it should parse new Date(date_string) and { error : “Invalid Date” } should return. I’ve tried shortening and/or altering the routes but nothing is working. What am I missing?
The tests are failing for input “05 October 2011” because you’re checking for “-” inside the string (which is missing for this case). If you read the failing test case carefully, you’ll have a hint what you should do:
Your project can handle dates that can be successfully parsed by new Date(date_string).
So instead of creating your own parser with multiple if…else cases you should just pass the input to new Date() and check if the result is valid or not.
Also, you can (and should) remove :date? from url.