I think i have everything covered but i dont understand what the failing for this means.
// running tests Your project can handle dates that can be successfully parsed by
new Date(date_string)
// tests completed
is it saying that if the url had something like '/api/fri-2005-12-5
im just not sure what case of input it is looking for me to handle.
here is my main get request with the useful code but also have my repl copied below.
app.get('/api/:date?', function(req, res){
let entry = req.params.date;
if(entry == null){
const empty = new Date().toUTCString();
const parsedDate= Date.parse(empty)
res.json({utc: empty, unix: parsedDate});
} else if(!entry.match(/-/g)){
entry = +entry;
const epochDate = new Date(entry);
const utcEpoch = epochDate.toUTCString();
res.json({utc: utcEpoch, unix: entry})
}
const myDate = new Date(entry);
if(myDate == 'Invalid Date'){
res.json({error: 'Invalid Date'})
} else {
const gmtDate = myDate.toUTCString();
const otherDate = Date.parse(myDate);
res.json({utc: gmtDate, unix: otherDate});
}
})
https://replit.com/@RobertWisnewski/boilerplate-project-timestamp#index.js