EvanHahn / HumanizeDuration.js

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

The examples in readme.md are not accurate #92

Closed ipeshev closed 8 years ago

ipeshev commented 8 years ago

The example for adding new language is not working ... shortEn: { y: function() { return 'y' }, mo: function() { return 'mo' }, w: function() { return 'w' }, d: function() { return 'd' }, h: function() { return 'h' }, m: function() { return 'm' }, s: function() { return 's' }, ms: function() { return 'ms' }, } ... when looking at the code it appears that , this should be written like this. shortEn: { year: function() { return 'y' }, month: function() { return 'mo' }, week: function() { return 'w' }, day: function() { return 'd' }, hour: function() { return 'h' }, minute: function() { return 'm' }, second: function() { return 's' }, millisecond: function() { return 'ms' }, }

EvanHahn commented 8 years ago

I just tried running this code and it worked for me:

var humanizeDuration = require('./')

var shortEnglishHumanizer = humanizeDuration.humanizer({
  language: 'shortEn',
  languages: {
    shortEn: {
      y: function() { return 'y' },
      mo: function() { return 'mo' },
      w: function() { return 'w' },
      d: function() { return 'd' },
      h: function() { return 'h' },
      m: function() { return 'm' },
      s: function() { return 's' },
      ms: function() { return 'ms' },
    }
  }
})

console.log(shortEnglishHumanizer(15600000))

Are you perhaps using an old version of the library?

ipeshev commented 8 years ago

Yes this should be the reason