Timestamp Microservice test fails

Test for submitting the project for the Timestamp Microservice fails.

A request to /api/:date? with a valid date should return a JSON object with a unix key that is a Unix timestamp of the input date in milliseconds - Fails

A request to /api/1451001600000 should return { unix: 1451001600000, utc: "Fri, 25 Dec 2015 00:00:00 GMT" } - Fails

Your project can handle dates that can be successfully parsed by new Date(date_string) - Fails

An empty date parameter should return the current time in a JSON object with a unix key - Fails

and the others pass.

Locally, it passes when I pass the date as 12-02-2021 , 12 02 2021, 1451001600000 or even Fri, 25 Dec 2015 00:00:00 GMT passes.

Can someone assist me with some resources to tackle this problem?

githubLink: GitHub - Otumian-empire/boilerplate-project-timestamp: A boilerplate for a freeCodeCamp project.

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0

Challenge: Timestamp Microservice

Link to the challenge:

if your probles is only with the test “Your project can handle dates that can be successfully parsed by new Date(date_string)”, triying the test with the app deployed in production, i use vercel. That was the only test that fails, but in production it worked, i dont know really why

1 Like

Your output:

{ utc: 1633397556000, unix: 'Tue, 05 Oct 2021 01:32:36 GMT' }

The required output:

{"unix":1451001600000, "utc":"Fri, 25 Dec 2015 00:00:00 GMT"}

You have the fields reversed.

You can link a git repo to a repl.it project and if you do, you’re more likely to get faster and better help since people can fork and test your repl.it project in a browser window with little effort.

1 Like

As per my understanding of your project, in the GET API where date_string is passed as params, you first need to check if the input is in unix timestamp(eg: 1451001600000) or a normal date format(12-02-2021) and then accordingly convert them into respective unix and UTC timestamps.

Same goes for this, you need to put such conditions that all test cases of passing dates gets covered.

1 Like

Thanks a lot. I have no excuse for not seeing that one.

1 Like

Hehe. No worries brother. At one point, it will become hard coded in your head because of the number of times we miss it in previous projects . :laughing:

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