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

Convert to ft-in #53

Open
mkaatman opened this issue Apr 9, 2020 · 1 comment
Open

Convert to ft-in #53

mkaatman opened this issue Apr 9, 2020 · 1 comment

Comments

@mkaatman
Copy link

mkaatman commented Apr 9, 2020

Would it be possible (and appropriate) for this library to convert to hybrid units where the whole number is the first unit and any remainder is the 2nd?

Something like:
const inches = unit(18, 'inches');
const footInches = inches.displayAs('ft-in', " - "); // "1 ft - 6 in"

Or is that use case better handled outside of this library?

@gurpreetatwal
Copy link
Contributor

Hi @mkaatman! Apologies for the horribly late response, I must have accidentally dismissed the notification 😞

Regarding your question, I think that could be a really neat feature to add to this library. There's some prior art for this in the moment.js library which has a method named humanize for doing pretty much exactly this except with durations of time.

It would be difficult to implement the interface as you suggested in the comment without resorting to some JavaScript trickery (since inches is just a number, not an object). We could do something like unit.humanize(inches, 'ft-in').

If you're willing to start off an implementation, we'd be more than happy to help design and review

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

No branches or pull requests

2 participants