What is the most proper way of comparing two dates, I have a holidays array from google, and dates fetched from react-day-picker, I transform them to be in JSON format with date.toJSON() method and with the dates from google I get following output:
0: "2020-12-24T00:00:00.000Z"
1: "2020-12-25T00:00:00.000Z"
2: "2021-04-04T00:00:00.000Z"
3: "2022-04-17T00:00:00.000Z"
Their time is zeroed and this is what I would like to end up with, however, when I run .toJSON() method on dates from react-day-picker I get
2021-10-21T10:00:00.000Z
2021-10-27T10:00:00.000Z
2021-10-28T10:00:00.000Z
2021-11-03T11:00:00.000Z
2021-11-04T11:00:00.000Z
they're with the locale time, and then I use date-fns to zero the hours with the set() method like so:
day = set(day, { hours: 0 }).toJSON();
2021-10-19T22:00:00.000Z
2021-10-20T22:00:00.000Z
2021-10-26T22:00:00.000Z
2021-10-27T22:00:00.000Z
2021-11-02T23:00:00.000Z
2021-11-03T23:00:00.000Z
2021-11-09T23:00:00.000Z
so I guess I am unable to get rid of the locale burden, and compare the dates? Or is there a method that could do that for me? Thanks a lot