Your first mistake is using Javascript's Date.
Js Joda is the only datetime library that doesn't make me wanna cry -> https://js-joda.github.io/js-joda/
It is kinda similar to the new Temporal api: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Or if you want to live on the edge: https://www.npmjs.com/package/temporal-polyfill
For experiments, I would strongly suggest to look into Temporal API.