codebox / moment-precise-range

A moment.js plugin to display human-readable date/time ranges
https://codebox.net/pages/moment-date-range-plugin
MIT License
150 stars 91 forks source link

wrong difference #20

Closed TrejGun closed 7 years ago

TrejGun commented 7 years ago

Hi there! I found a bug

const start0 = moment("2016-12-08T00:00:00.000Z");
const end0 = moment("2016-12-08T22:59:58.999Z");
console.log(moment.preciseDiff(start0, end0)); // 22 hours 59 minutes a few seconds

const start1 = moment("2016-12-08T00:00:00.000Z");
const end1 = moment("2016-12-08T23:59:59.999Z");
console.log(moment.preciseDiff(start1, end1)); // a day 59 minutes a few seconds

const start2 = moment("2016-12-08T00:00:00.000Z");
const end2 = moment("2016-12-09T00:00:00.000Z");
console.log(moment.preciseDiff(start2, end2)); // a day
TrejGun commented 7 years ago

sorry I had outdated version