jsmreese / moment-duration-format

Format function plugin for the Moment Duration object.
MIT License
967 stars 121 forks source link

Sometimes show "0 seconds" #142

Open ghost opened 4 years ago

ghost commented 4 years ago

When moment.duration is "604800000" it shows 1 week, but when moment.duration is "604800100", it shows 0 seconds instead of 1 week, 0 days, 0 hours, 0 minutes and 1 second.

image image image

const moment = require("moment");
require("moment-duration-format");
moment.updateLocale('en', {
    durationLabelsStandard: {
        s: "second",
        ss: "seconds",
        m: "minute",
        mm: "minutes",
        h: "hour",
        hh: "hours",
        d: "day",
        dd: "days",
        w: "week",
        ww: "weeks",
        M: "month",
        MM: "moths",
        y: "year",
        yy: "years"
    },
})
const duration = moment.duration("3660000").format(`y __, M __, w __, d __, h __, m __ [and] s __`);

console.log(duration)