EvanHahn / HumanizeDuration.js

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

[Bug] - Add new languages to humanizers. #160

Closed saeta-eth closed 5 years ago

saeta-eth commented 5 years ago

Hi.

I just followed the example provided on the docs to add a new language.

const shortEnglishHumanizer = humanizeDuration.humanizer({
  language: 'shortEn',
  languages: {
    shortEn: {
      y: () => 'y',
      mo: () => 'mo',
      w: () => 'w',
      d: () => 'd',
      h: () => 'h',
      m: () => 'm',
      s: () => 's',
      ms: () => 'ms',
    },
  },
});

After that, I have received: 1 m, 11undefined75 s from 71750 milliseconds.

Thanks for this awesome library.

EvanHahn commented 5 years ago

This looks like a bug. To fix this in the short term, add a decimal option:

const shortEnglishHumanizer = humanizeDuration.humanizer({
  language: 'shortEn',
  languages: {
    shortEn: {
      // ...
      decimal: '.'
    },
  },
});

I'll plan to fix this soon.

EvanHahn commented 5 years ago

This has been fixed in humanize-duration@3.20.1. Thanks for reporting!