Open rfire12 opened 3 years ago
When day and month are too close between each other, e.g.: 2021-01-17 and 2015-02-04, years throws 6 as the year difference instead of 5.9~ish
years
Using years with these dates: 2021-01-17 and 2015-02-04 should return 5.9~ish instead of 6.
import DateDiff from 'date-diff'; const diff = new DateDiff( new Date(2021, 01, 17), new Date( 2015, 02, 04 ) ); console.log(diff.years()); // output: 6
Windows 10 - WSL 2 node v10.20.1
A workaround is to use months instead of years, and then calculate the years difference from that.
months
Current Behaviour
When day and month are too close between each other, e.g.: 2021-01-17 and 2015-02-04,
years
throws 6 as the year difference instead of 5.9~ishExpected Behaviour
Using
years
with these dates: 2021-01-17 and 2015-02-04 should return 5.9~ish instead of 6.Steps to Reproduce
Environment 🌎
Windows 10 - WSL 2 node v10.20.1
A workaround is to use
months
instead ofyears
, and then calculate the years difference from that.