Open tncbbthositg opened 2 years ago
In this code for example:
const moment = require('moment'); const momentDurationFormat = require("moment-duration-format") const endDate = moment('2022-03-18'); const startDate = moment('2021-11-16'); const duration = moment.duration(endDate.diff(startDate)); console.log(duration.asDays()); console.log(duration.format("M __ D __", { trim: 'all' }));
The output is:
121.95833333333333 "4 months -0 days"
This is the case in moment-duration-format v2.3.2.
I can work around this like so:
const diff = endDate.diff(startDate); const wholeDayDuration = moment.duration(Math.round(diff / 86400000) * 86400000);
Effectively, the missing hour due to the daylight savings time change is causing a -0 to show up in the duration format.
In this code for example:
The output is:
This is the case in moment-duration-format v2.3.2.
I can work around this like so:
Effectively, the missing hour due to the daylight savings time change is causing a -0 to show up in the duration format.