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

TimeSpan.Humanize should offer an "age" format #968

Closed
louis-z opened this issue Aug 26, 2020 · 2 comments · Fixed by #1068
Closed

TimeSpan.Humanize should offer an "age" format #968

louis-z opened this issue Aug 26, 2020 · 2 comments · Fixed by #1068

Comments

@louis-z
Copy link
Contributor

louis-z commented Aug 26, 2020

Using a TimeSpan to express an age, I would like to output that information in one of 2 ways

  • either as an hyphenated adjectival phrase (e.g. a "10-week-old" cat), or
  • as a non-hyphenated phrase (e.g. the cat is "10 weeks old")

If you feel it would benefit the product, I'd be interested in implementing it.

@louis-z
Copy link
Contributor Author

louis-z commented Sep 4, 2020

I mentioned using the Humanize method for this, but it would require adding at least one new optional parameter, right? Would it make more sense to introduce new extension methods for TimeSpan instead? I was thinking of something along the lines of:

  • ToHyphenatedAge() for the pre-noun adjective form ("a 10-year-old cat") or noun form ("the 10-year-old")
  • ToAge(), for the post-noun adjective form ("the cat is 10 years old")

Not quite sure how to better express it succinctly... 🤔 Suggestions are welcome.

@louis-z
Copy link
Contributor Author

louis-z commented Sep 24, 2020

For non-English cultures, maybe

  • ToAge() could return the same thing as Humanize(maxUnit: TimeUnit.Year) (until someone defines a different culture-specific behavior, if need be)
  • ToHyphenatedAge could simply return an empty string (as most cultures know nothing about hyphenated age, what other default value would make more sense?)

@clairernovotny,
@MehdiK,
what do you think?

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.

1 participant