Issue regarding time conversion

The whole project is working but the last test is not passing.
On further investigation i think the issue lies in comparing the dates residing in the database and the dates being sent in the query parameter.

I convert both to the Date object for comparison.
But the date stored in the database is in this format ‘Sun Jan 01 1995’
This converts to 1994-12-31T18:30:00.000Z

while the date sent in the query param being 1995 is converted to:
1995-01-01T00:00:00.000Z

This 5:30 hr gap is probably due to me being in india and the Date() accounting for the local time. I am unable to figure out what to do about it.

Can someone suggest a way around or even a better way to deal with the problem?

Your project link(s)

solution: https://etms-ojasthakur.herokuapp.com
githubLink: ===https://github.com/ojasthakur/FCC-exercise-tracker-microservice.git===

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36

Challenge: Exercise Tracker

Link to the challenge:

Well after wasting an entire day i opted for the cheaper route. I passed the query date through Date().toDateSting() and then again the output through Date() which outped date with the same offset as the one the database date was outputting. The comparison hence worked with both the server date and the query date having the same offset.

Another issue came up that the logs were coming up empty in some cases when setting the limit to 1. This was happening as i had applied the limit to the data being fetched, which resulted in some of the values not being tested in the from/to conditions (these were the values that were actually going to pass).
Another cheap fix by using arr = arr.slice(0, limit) after all the sifting through was already done. Now I can finally enjoy some coffee instead of taking it as medicine :smiley: