Skip to content

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.

1 participant