Timestamp Microservice keeps failing tests

Tell us what’s happening:
So I went at the Timestamp Microservice challenge and put together a script that works. As in, every test completes except for one.

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

Now, I thought I knew what this meant and went to make certain my application can parse every potential input method as the documentation offers.

new Date()
new Date(value)
new Date(dateString)
new Date(dateObject)

new Date(year, monthIndex)
new Date(year, monthIndex, day)
new Date(year, monthIndex, day, hours)
new Date(year, monthIndex, day, hours, minutes)
new Date(year, monthIndex, day, hours, minutes, seconds)
new Date(year, monthIndex, day, hours, minutes, seconds, milliseconds)

Of this, it correctly covers the lower six, down to milliseconds (which the example does not do; on that note, the example also parses /api/2019,11 as ‘November 2019’ instead of December as it should.

I did not check for dateObject, but figure it is not possible to pass one of those via URL. value works just fine.

The only issue is dateString, which acts erratically. Some strings it accepts in quotation marks (e.g. '01 Jan 1970 00:00:00 GMT'), some it declares invalid with them but accepts without them (e.g. 'December 17, 1995 03:24:00' fails but December 17, 1995 03:24:00 works; this is the exact same in the example application).

So… I am uncertain what to do now. Removing quotation marks yields errors and every other input works. Help would be appreciated.
(Edit: I implemented proper code cleanup to remove quotation marks to check; it works now, regardless of whether the input has or lacks them. It does not allow to pass that final test, though. Which puts me entirely out of ideas for what may be wrong.)

Your project link(s)
As this is a certification challenge, I rather not provide the code itself. Here is the site I built (Edit: removed because it now links to a working solution).

Your browser information:

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

Challenge: Timestamp Microservice

Link to the challenge:

After some more fiddling and asking a friend for input, I revamped the code. It works now, but I still do not know why the previous one failed.

Project link removed so no one can get an odd idea with a working solution.

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