Tell us what’s happening:
Describe your issue in detail here.
I can’t pass the test for ‘Your project can handle dates that can be successfully parsed by new Date(date_string)’
Can’t understand what I’m doing wrong.
Your project link(s)
solution: https://replit.com/@1nfernox/boilerplate-project-timestamp
The code I have is:
let responseObject = {};
app.get('/api/:input', function(req, res) {
let input = req.params.input;
if(input.includes('-')){
responseObject['unix'] = new Date(input).getTime()
responseObject['utc'] = new Date(input).toUTCString()
} else {
input = parseInt(input)
responseObject['unix'] = new Date(input).getTime()
responseObject['utc'] = new Date(input).toUTCString()
};
if (/\d{5,}/.test(input)){
input = parseInt(input);
responseObject['unix'] = input;
responseObject['utc'] = new Date(input).toUTCString();
} else {
responseObject['unix'] = new Date(input).getTime()
responseObject['utc'] = new Date(input).toUTCString()
};
if(!responseObject['unix'] || !responseObject['utc']){
res.json({error : "Invalid Date"})
};
res.json(responseObject);
});
app.get('/api', function(req, res) {
responseObject['unix'] = new Date().getTime()
responseObject['utc'] = new Date().toUTCString()
res.json(responseObject);
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0
Challenge: Timestamp Microservice
Link to the challenge:
