MCPcopy Index your code
hub / github.com/deployd/deployd / parseTime

Function parseTime

test-app/public/sinon.js:27809–27835  ·  view source on GitHub ↗

* Parse strings like "01:10:00" (meaning 1 hour, 10 minutes, 0 seconds) into * number of milliseconds. This is used to support human-readable strings passed * to clock.tick()

(str)

Source from the content-addressed store, hash-verified

27807 * to clock.tick()
27808 */
27809 function parseTime(str) {
27810 if (!str) {
27811 return 0;
27812 }
27813
27814 var strings = str.split(":");
27815 var l = strings.length;
27816 var i = l;
27817 var ms = 0;
27818 var parsed;
27819
27820 if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
27821 throw new Error("tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits");
27822 }
27823
27824 while (i--) {
27825 parsed = parseInt(strings[i], 10);
27826
27827 if (parsed >= 60) {
27828 throw new Error("Invalid time " + str);
27829 }
27830
27831 ms += parsed * Math.pow(60, (l - i - 1));
27832 }
27833
27834 return ms * 1000;
27835 }
27836
27837 /**
27838 * Get the decimal part of the millisecond value as nanoseconds

Callers 1

createClockFunction · 0.85

Calls 1

parseIntFunction · 0.85

Tested by

no test coverage detected