Back End Development and APIs Projects - Timestamp Microservice

Tell us what’s happening:
My solution currently passes all the tests except for the " Failed:Your project can handle dates that can be successfully parsed by new Date(date_string)" one. I’d really appreciate if you can help me out

Your project link(s)

solution: (for some reason, the forum isn’t allow me post the link to the deployed api, but it’s right there in my repo README)

githubLink: GitHub - codeHokage1/fcc_timestamp_microservice

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: Back End Development and APIs Projects - Timestamp Microservice

Link to the challenge:

Request:

https://fcc-timestamp-microservice-one.vercel.app/api/05%20October%202011,%20GMT

Response:

{"unix":null,"utc":"Invalid Date"}

The string ‘05 October 2011, GMT’ does not match any of your conditions and gets passed to this code.

res.json({
  "unix": Number(req.params.date),
  "utc": new Date(Number(req.params.date)).toUTCString()
})

Incorrectly parsed

Number('05 October 2011, GMT')
NaN

JSON.stringify(Number('05 October 2011, GMT'))
'null' 

new Date(Number('05 October 2011, GMT')).toUTCString()
'Invalid Date'

Correctly parsed:

new Date('05 October 2011, GMT')
Wed Oct 05 2011 02:00:00 GMT+0200 (Central European Summer Time)
1 Like

I see!
Thank you very much for pointing that out.

I’ve corrected it and it passes all tests now
Thanks again!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.