Closed markscamilleri closed 12 months ago
@vipzhicheng sorry for tagging but I haven't received any feedback for 2 weeks 😅
Dose this pr can resolve #34 ? Hope release soon
Not sure - but I can have a look later this week. Though I suspect that this might be a separate issue, as I replaced the parts of obtaining the last day in the month 😅
Sorry for the delay and thanks for your PR. I have reproduced the issue and tested your code. It works perfectly. Will add it to the next release.
I noticed that the leap years were being calculated incorrectly, by using the divisible by 4 method. Unfortunately, this method does not take into account that leap years that are divisible by 100 are not leap years unless they are also divisible by 400 (source)
As a result, and becuase I noticed that
dayjs
also provides a helper function to get the days in a month, I thought it would make sense (and make the code cleaner) to use that helper function.I also took the liberty of writing a few (imperfect) tests for this including some snapshot tests to help test the output of the
setCal
function. For the tests, although I wanted to usenode:test
, I had to installjest
as my environment was not able to locatenote:test
. I'm happy to change to another framework or evennode:test
and try get it working on my environment.