Hola , me gustaría saber porque no paso esta prueba.
Será que no debo usar regex?
EDIT: Todas las demas pruebas si dieron positivo.
EDIT 2: code
app.get('/api/', function(req,res){
const now = new Date()
res.json({unix: Date.parse(now), utc: now.toUTCString()})
})
app.get('/api/:q',(req,res)=>{
let fecha;
const parametro = req.params.q;
const regexs = [/^\d+$/, /\d{3}-\d{2}-\d{2}/];
if(regexs[0].test(parametro)){
fecha = new Date(Number(parametro))
} else if(regexs[1].test(parametro)){
fecha = new Date(parametro);
} else {
return res.json({error: "Invalid Date"})
}
const unix = Date.parse(fecha);
const utc = fecha.toUTCString();
res.json({unix: unix, utc: utc});
})
