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

Update durations() param to take an array of units #675

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

parulsingh23
Copy link
Contributor

@parulsingh23 parulsingh23 commented Dec 25, 2020

This update also includes a bug to the duration function providing too many terms (i.e. for duration(10000000,1) it provides "2 hours, 46 minutes, 40 seconds"), but that was fixed with adding some additional checks in the for loop's if-else statements.
With this update, you can (instead of providing a terms param with the limiting number of units) provide the param with the array of unit types desired. That unit array can be unordered, and if none of the terms 'fit' in the milliseconds provided, then the smallest-magnitude unit along with 0 is returned (in no other cases will a zero term be displayed).
EX: duration(1, [seconds, days, hours]) returns [“0 seconds”] & duration(60 * 60 * 1000+2000, [hours, ms]) returns ["1 hour", "2000 ms"]

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 this pull request may close these issues.

None yet

1 participant