EvanHahn / HumanizeDuration.js

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

[feature] duration in the past and future #212

Closed cmldk closed 1 year ago

cmldk commented 1 year ago

Can I implement duration in the past as an additional option? @EvanHahn

I will add an extra option for the feature for both the past and future. While calling the function, the option will be like that:

options = {
  ...
  adverb_of_time: true
}

Then I will add extra keys for the past and future according to languages as shown below.

dictionary = {
  ...
  en: {
    ...
    past: "in %s",
    future: "%s ago"
  }
  ...
}
EvanHahn commented 1 year ago

This library is actively maintained but no new features will be added. I like this feature request but don't plan to add it.

If you'd like to fork and add this feature, feel free! I can link to your code from the readme.

cmldk commented 1 year ago

@EvanHahn. Thank you for your response. I completed the feature. You can check the file and commits using the GitHub fork repo here.

The example codes are below the timeAdverb title in Readme. Also, I added a code snippet for testing in test/humanizer.js

EvanHahn commented 1 year ago

Thanks. I'll take a look at this.

EvanHahn commented 1 year ago

Added it to the readme in 6afef107949bea4fc6edf5b2b0cd91cbbc646a3c.

Thanks!