Microservice timestamp project help

Tell us what’s happening:

cannot pass one test for api to return unix microstamp
my repl it code link is


Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; SM-A107F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.111 Mobile Safari/537.36.

Challenge: Timestamp Microservice

Link to the challenge:

Tell us what’s happening:
i passed in all the test except in test 3 where it says to return a unix api. please help.
my repl it link:
urlhttps://repl.it/@meeramenon07/boilerplate-project-timestamp-1#server.js

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; SM-A107F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.111 Mobile Safari/537.36.

Challenge: Timestamp Microservice

Link to the challenge:

Hi @meeramenon07 , if you test you api for the failing case you get the following output:

TypeError: input.getTime is not a function

Which originates from here:

  if(/\d{5,}/.test(input)){
    input = parseInt(input);
    responseObject['unix'] = input.getTime();

Which makes sense as there’s not getTime method defined for a number. Perhaps you meant to convert it to a Date object first?

Hope it helps :sparkles:

oh yes, thanks, will work on it again

Tell us what’s happening:
I passed all the test for this challenge except the test that requires that a request for api/timestamp/1451001600000 should return {unix:1451001600000; utc:“Fri, 25 Dec 2015 00:00:00zGMT”}
when I test my api with utc it works but when i test with value of above unix , I cannot get this result. Please check my repl it file link:

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; SM-A107F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.111 Mobile Safari/537.36.

Challenge: Timestamp Microservice

Link to the challenge:

server.js on line 37, your if statement checks if input includes an empty string, which for timestamp will be true, then you try to create a date from that timestamp string, which results in NaN, which then on line 48 will result in true which will send “Invalid Date” response.

Tell us what’s happening:
My project passing all tests and I also tested correctly for. both unix and utc dates and it works however now there is one test thats not passing that says "your project can handle dates that can be successfully parsed by new Date(date_String)

my repl it file link :

solution: https://boilerplate-project-timestamp-1.meeramenon07.repl.co

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; SM-A107F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.111 Mobile Safari/537.36.

Challenge: Timestamp Microservice

Link to the challenge:

It should work when I try to use it like this for example:

api/timestamp/05 October 2020

At the moment the response I got is:

{
  "unix": 5,
  "utc": "Thu, 01 Jan 1970 00:00:00 GMT"
}

yes it works when i test it but on fcc challenge they are not passing me for this test :slight_smile:

What I mean is that it is not correct behaviour. For “05 October 2020” it should send the following response:

{
  "unix": 1601856000000,
  "utc": "Mon, 05 Oct 2020 00:00:00 GMT"
}

It’s expected that also a valid “string date” in the url will work as @sitek94 mentioned.

For example having december 25 21 as the date input should work.
As a matter of fact on the fcc example project is does:

"/api/timestamp/december 25 21"
{"unix":1640390400000,"utc":"Sat, 25 Dec 2021 00:00:00 GMT"}

While on yours it will return “Invalid date”

"/api/timestamp/december 25 21"
{"error":"Invalid Date"}

That’s due to the fact that in your source code you check that the input either includes - or is a number, but never account for “strings”.

Hope it helps :sparkles:

oh i see. ok thanks .will try that

ok will edit my code

Now I included strings in the code do I passed the above test vut now Iam failing another test that I passed earlier:"a request to/ api/timestamp/1451001600000 should return {unix:1451001600000, utc:“Fri, 25 Dec 2015 00:00:00 GMT”}

I am passing this test after invluding string in my code but now failing in another test that says "request to /spu/timestamp/1451001600000 should return unix and utc date s. :frowning:

Tell us what’s happening:
I edited my code and passed all tests but cannot pass one test that requests:a request to /api/timestamp/1451001600000 should return {unix:1451001600000; utc:“Fri, 25 Dec 2015 00:00:00 GMT”}

please help.
my repl it file link :
https://repl.it/@meeramenon07/boilerplate-project-timestamp-1#server.js

Your project link(s)

solution: https://boilerplate-project-timestamp-1.meeramenon07.repl.co

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; SM-A107F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.111 Mobile Safari/537.36.

Challenge: Timestamp Microservice

Link to the challenge:

1 Like

When you send GET request like this:

/api/timestamp/141241412421

The input will be string.

let input = request.params.input

So this condition will be true:

input.includes('')

And your input will be parsed as string not as timestamp.

1 Like

ok, so in the parseInt code statement, I should not write the if condition for string. I suppose?

1 Like

Thanks a lot . I fixed my code. now I passed!!
thanx again.