Backend - TimeStamp Microservice: "Your project can handle dates that can be successfully parsed by new Date(date_string)"

One last spec to pass. Can anyone enlighten me what the spec means with this message?
Your project can handle dates that can be successfully parsed by new Date(date_string)

What is it looking for? What’s the test case? Is it relevant to this:
testDate[Symbol.toPrimitive]('string'); // Returns Date Fri May 29 2020 14:05:17 GMT+0100 (British Summer Time)?

in this link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/@@toPrimitive?

If yes, in what way (again, what’s the test case for me to work it)?

Thank you!

Your project link(s)

solution: https://replit.com/@shugyoza/boilerplate-project-timestamp

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36

Challenge: Timestamp Microservice

Link to the challenge:

I happen to come across the same error today and took 3 hours to solve it.

Basically what it means is the date what you obtain from req.params.date should parse the date into numbers.

Example if date: 25 oct 2015 is passed as input in /api/25oct2015. It should parse the string and obtain the correct date.

Use a regular expression for parsing the input date. That should solve the issue.

1 Like

Thanks! I’ve just realized that. That even if the user input /api/25 oct 2015, my app should render the corresponding unix and utc. Thanks!

1 Like