EvanHahn / HumanizeDuration.js

361000 becomes "6 minutes, 1 second"
https://evanhahn.github.io/HumanizeDuration.js/
The Unlicense
1.64k stars 175 forks source link

Make UNITS configurable #76

Closed dimitri-koenig closed 9 years ago

dimitri-koenig commented 9 years ago

If you want to humanize durations for worktime measures, where e.g. 1 day has only 8 hours, you have to be able to modify UNITS. Therefore it would be great to extend these unit measures via options.

In this example I only duration till "weeks" but each week has 40h and each day has 8h, therefore:

var myHumanizer = humanizeDuration.humanizer({
    units: ['w', 'd', 'h', 'm', 's'],
    unitMeasures: {
        w: 144000000,
        d: 28800000,
        h: 3600000,
        m: 60000,
        s: 1000,
        ms: 1
    }
});
EvanHahn commented 9 years ago

This looks good! Could you add some tests (probably in test/humanizer.coffee)?

dimitri-koenig commented 9 years ago

Sure, here we go

EvanHahn commented 9 years ago

Added in humanize-duration@3.3.0!

dimitri-koenig commented 9 years ago

Thx! You're awesome!