Cant pass the last test case i have tried many things

i have been doing this since weeks but it is failing at last test case

here is my code

const express = require('express')
const app = express()
const cors = require('cors')

var bodyParser = require("body-parser");
const mongoose = require("mongoose");
mongoose.connect('mongodb+srv://',{useNewUrlParser: true, useUnifiedTopology: true});

var db = mongoose.connection;

app.use(express.urlencoded({extended: true}));

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/views/index.html')

//mongoose.set('useFindAndModify', false)

const listener = app.listen(process.env.PORT || 3000, () => {
  console.log('Your app is listening on port ' + listener.address().port)

const Schema = mongoose.Schema;
const userSchema = new Schema({
  username: {
    type: String,
    required: true},
  count: Number,
  log: [{
    description: String,
    duration: Number,
    date: {type: String, required: false},
    _id: false

const User = mongoose.model("User", userSchema);"/api/users", (req,res)=>{
    var user = new User({
      username: req.body.username
    if(err) return console.error(err);
      username: data.username,
      _id: data._id

app.get("/api/users", (req,res)=>{
    User.find({}, function(err,list){

const dateValidation = (input) =>{
  if(input === undefined){
    return new Date().toDateString()
  else {
    return new Date(input).toDateString()
};"/api/users/:_id/exercises", (req,res)=>{
 let exercise = {
        description: req.body.description,
       duration: parseInt(req.body.duration),
       date: dateValidation(
  User.findOneAndUpdate ({_id: req.params._id}, exercise, {new: true}, (err,data)=>{
        error: err
      console.log("saving exercise");
        username: data.username,
        _id: req.params._id,
        description: exercise.description,
        duration: exercise.duration,
app.get("/api/users/:_id/logs?", (req,res)=>{
   User.findById(req.params._id, (err,data)=>{
      let dataset = data.log;
     if (err) {res.send ({error: err}) }
        dataset = data.log.filter((item)=>
          new Date( >= new Date(req.query.from).getTime() && new Date( <= new Date(
        dataset =data.log.filter((d,i)=> i < req.query.limit )
        _id: data._id,
      username: data.username,
      from: new Date(req.query.from).toDateString(),
      to: new Date(,
      count: dataset.length,
        log: dataset

Your browser information:

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

Challenge: Exercise Tracker

Link to the challenge:

I can’t replicate the last test failure with your code. I did log the inputs and outputs to the route, and you’re returning the right number of log entries, but not always the right ones because your from, to, and limit handling is not exactly correct, just correct enough to pass the tests. Log your route inputs and outputs if you’re curious.

I did get the penultimate test to fail, but that’s expected since I ran the tests during the time that would trigger the timezone offset bug for this project.

Run the tests when your local date is the same as the UTC date, and if the last two tests don’t pass, try logging your route inputs and outputs. If that doesn’t help you resolve the problem, then post a link to a with the problem so we can debug the same project and avoid anything that might accidentally mask the problem.

[url of code]boilerplate-project-exercisetracker - Replit
have a look