Hello, I have done the time stamp micro service project and it keeps failing one test:
Your project can handle dates that can be successfully parsed by new Date(date_string).
I don’t know exactly what it means but I think it has something to do with the fact that I have used the Luxon library instead of the library that is used by fcc.
Thanks for your time .
I modified this relevant bit of your code with some logging:
//If there is any letter in the request, return invaliid date
if (/[a-zA-Z]/.test(input)) {
console.log(input);
console.log({error: "Invalid date", details: "The date contains letters"});
return res.json({error: "Invalid date", details: "The date contains letters"});
}
This test is sending 05 October 2011, and that is parseable by Date(). My modifications above yield
05 October 2011
{ error: 'Invalid date', details: 'The date contains letters' }
on the console. However, it’s a valid date. Always log your route inputs and outputs when debugging. It’s the first thing I do after I break something.
Your project can handle dates that can be successfully parsed by new Date(date_string)
new Date('05 October 2011') returns a valid date (try it in browser console), but your code thinks it’s an invalid date.
I think you’ve just over complicated the input parsing. Instead of just trying to create a date from the input and see if it’s valid, you’re trying to re-implement Date constructor.