Skip to content
This repository has been archived by the owner on Apr 9, 2018. It is now read-only.

Return a default meaningful text to replace NotSupportedException #2

Open
yufeih opened this issue May 25, 2015 · 4 comments
Open

Return a default meaningful text to replace NotSupportedException #2

yufeih opened this issue May 25, 2015 · 4 comments

Comments

@yufeih
Copy link
Contributor

yufeih commented May 25, 2015

There are 2 ways for TimeAgo to throw NotSupportedException:

  1. The culture info is not supported, in this case we can fallback to English
  2. The time is exactly now or somewhere in the future, in this case we can say "in 10 hours" just like in momentjs.com
@NickStrupat
Copy link
Owner

I'm happy to add an overload or configuration to specify a default CultureInfo, but I don't think falling back to English silently is a good fit here.

I really like the idea of adding the ability to work with DateTimes in the future. I cut that out of scope originally, but I'm into the idea now.

@NickStrupat
Copy link
Owner

Thanks for your pull requests, btw!

@yufeih
Copy link
Contributor Author

yufeih commented May 29, 2015

Fallback to en (or the default culture) is all about making sure no exceptions are throwing calling TimeAgo method. Because the use case of TimeAgo is more like ToString, and the best practices to override System.ToString is

Your ToString override should not throw an exception.

@NickStrupat
Copy link
Owner

I like your reasoning. I'm sold. I'll try to get that change done this week and start on the 'from now' work hopefully.

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

No branches or pull requests

2 participants