EvanHahn / HumanizeDuration.js

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

Conjunctions #102

Closed rausnitz closed 8 years ago

rausnitz commented 8 years ago

This adds an option for using a conjunction rather than the final delimiter. For example, the output could be 3 days and 14 minutes or 3 hours, 1 minute & 14 seconds.

jsejcksn commented 8 years ago

@rausnitz Would you consider using the serial comma in your addition? It would provide a consistency in separation of units as well as being consistent with how JavaScript uses lists (arrays), without sacrificing the increased natural language it affords.

Instead of "the conjunction rather than the final delimiter", "inserting the conjunction between the final delimiter and final value when there are three or more values": 3 days and 14 minutes or 3 hours, 1 minute, and 14 seconds

I understand that people opine strongly about style, so I'm not offended in the slightest if you don't agree with me, but I just want to throw the idea out there for consideration.

EvanHahn commented 8 years ago

I agree about the serial comma. Perhaps there's a way to make it configurable?

rausnitz commented 8 years ago

I like serial commas too. I'll have an update in shortly.

rausnitz commented 8 years ago

It now prepends a serial comma to the conjunction if there are more than two values. People can opt out by using the serialComma: false option.

EvanHahn commented 8 years ago

I merged this into a new conjunctions branch. I'm a bit busy and don't want to rush a release out, but this looks good and should be ready soon.

Thanks!

EvanHahn commented 8 years ago

This is released in Humanize Duration 3.8.0! Thanks for your contribution.