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

Request: Measure of length #526

Open
mgnslndh opened this issue Feb 10, 2016 · 5 comments · May be fixed by #775
Open

Request: Measure of length #526

mgnslndh opened this issue Feb 10, 2016 · 5 comments · May be fixed by #775

Comments

@mgnslndh
Copy link

I think it would make a good addition to Humanizer if it was possible to humanize length just like time (as with TimeSpan).

Example of how the API could look like. I guess there are more to this feature but it is a start:

var value = 1280; // millimeters
value.ToLength(precision: 1, fromUnit: LengthUnit.Millimeters, minUnit: LengthUnit.Meter, maxUnit: LengthUnit.Meter);

value would become "1.3 m"

@aloisdg
Copy link
Contributor

aloisdg commented Mar 17, 2016

@mgnslndh Did you try the metric converter? Does it fit your needs? How can it be improve?

@salvador-guerrero
Copy link

I'd like to suggest a way to limit the range of prefixes used, let's suppose we are trying to humanize distances

100d.ToMetric() + "m";   //Result: 100m
2000d.ToMetric() + "m";  //Result: 2km
5000000d.ToMetric() + "m" //Result: 5Mm

The last result is not very useful, a Megameter is a SI unit, but i'd rather have 5000km as a result

JonasBarka added a commit to JonasBarka/Humanizer that referenced this issue Jan 2, 2019
JonasBarka added a commit to JonasBarka/Humanizer that referenced this issue Jan 3, 2019
@JonasBarka
Copy link

JonasBarka commented Jan 3, 2019

I've just started implementing this request, as my first contribution to an open source project!

My current plan is to add an optional parameter to ToMetric named largestPrefix. Setting it to a new enum MetricPrefix will place an upper limit to the used prefix.

I got some questions that I hope you can help me with:

  1. As you know, naming is hard. Do you got any suggestions for the parameter name you feel is better than largestPrefix ?
  2. Would there be a use for a corresponding smallestPrefix option? I like it for symmetry but I can't think of any common real world use cases.
  3. The contribution instruction references the dev branch. I can't find any general and up to date dev branch. Should it be master?
  4. I do not got access to ReSharper. How do you suggest I satisfy the requirement to have no ReSharper warnings?
  5. I'm unsure of when to end a sentence with a period and when to leave it out in the Xml documentation. What are the rules?
  6. The use of copyright notices in individual files seems to vary wildly. Is there a recommended way in to do it in this project?

Thank you for any help with my questions, or other suggestions for an open source noob! :)

(Edit: Changed parameter type to enum.)

@JonasBarka
Copy link

My current names are maxPrefix and minPrefix. Short and max/min is very common in programming.

@aloisdg
Copy link
Contributor

aloisdg commented Jan 9, 2019

@JonasBarka Your comment make me think that you could open an issue about your contribution question. This issue could result in a PR to the Contribute.md file. :)

@JonasBarka JonasBarka linked a pull request Jan 18, 2019 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants