A Meteor package for converting seconds to a duration format of HH:MM:SS
.
meteor add chipcastledotcom:seconds-conversion
Here's an example of converting 60
seconds to the duration format:
SecondsConversion.duration(60);
This would return 1:00
because 60 seconds is equal to 1 minute and
0 seconds. The format returned does not pad values with zeros, nor does
it show zeros unecessarily (e.g., 00:01:00
).
Here's another example where theres a conversion of 360000
seconds:
SecondsConversion.duration(360000)
This would return '100:00:00', which is to demonstrate how the hours
formatting can be extended beyond the 2-digit HH
format. Formatting
for days, weeks, months, etc. has not been supported because it was
unnecessary for my needs.
Please note that the duration
function accepts only integers.
Software provided under the MIT License.
Please fork this repo and write tests.
From within this repository's directory:
meteor test-packages ./