index.js 209 B

12345678910111213
  1. 'use strict';
  2. module.exports = function (str) {
  3. var parts = str.split(':');
  4. var sec = 0;
  5. var min = 1;
  6. while (parts.length > 0) {
  7. sec += min * parseInt(parts.pop(), 10);
  8. min *= 60;
  9. }
  10. return sec;
  11. };