Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow TimeSpanHumanizeExtensions.Humanize to take a maximum TimeUnit. #383

Closed
mthamil opened this issue Feb 21, 2015 · 1 comment · Fixed by #384
Closed

Allow TimeSpanHumanizeExtensions.Humanize to take a maximum TimeUnit. #383

mthamil opened this issue Feb 21, 2015 · 1 comment · Fixed by #384

Comments

@mthamil
Copy link
Contributor

mthamil commented Feb 21, 2015

I have had this issue come up at my job. I wanted to use Humanizer for sending token lifespans in emails. For example, "Click the link above, etc. This link will expire in {X minutes/days/whatever}."

Our requirements/marketing people seem to prefer displaying 7 days or 30 days instead of weeks. I looked over the code and didn't see an existing way to make this happen (except for getting a formatter and duplicating some of the existing code with tweaks).

I went home, forked Humanizer, coded, and tested a solution. I was wondering if this would be considered viable or valuable?

The change involves adding a parameter to the methods, TimeUnit maxUnit, which is defaulted to Weeks. I also implemented this down to milliseconds (ie. display 1000 milliseconds instead of 1 second).
It's backward compatible.

Thoughts?

@MehdiK
Copy link
Member

MehdiK commented Feb 23, 2015

Thanks for the message.

I like it. Please submit a PR and we'll review it. Please follow the contribution guideline for your PR. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants