agenda / human-interval

Human readable time distances for javascript
Other
459 stars 13 forks source link

Use something like `node-numbered` to convert words in numbers #9

Closed faridnsh closed 3 years ago

faridnsh commented 7 years ago

Hello @rschmukler ,

To support more word numbers, instead of adding more data, we could use something like node-numbered to do this and remove some code from the project while extending it's support. Would you be accepting such contribution? What do you think?

I suppose, to use that there needs to be a little bit of refactoring on how the code works. I'm thinking we could instead use the following algorithm:

  1. Find the units in the string and split the string using them.
  2. Pass the remaining strings to node-numbered which will convert them to numbers.
  3. Process it and calculate the total.
simison commented 6 years ago

Hey @alFReD-NSH,

I think that's a great idea.

~Note that floats like 0.259 we will probably need to Math.round().~ Actually nope! Should work just like that. Just need to check how many decimals is ok.

We've just recently moved this repo under @Agenda org. Would you feel like submitting a PR + tests for this? That would be sooooo helpful.