function toMS(input) {
const sRegex = /\d+s/g;
const msRegex = /\d+ms/g;
const usRegex = /\d+us/g;
Logger.log("Running toMS with parameter: " + input);
var sToMs = 0;
var msToMs = 0;
var usToMs = 0;
while((seg = sRegex.exec(input)) !== null) {
sToMs += parseInt(seg) * 1000;
}
while((seg = msRegex.exec(input)) !== null) {
msToMs += parseInt(seg);
}
while((seg = usRegex.exec(input)) !== null) {
usToMs += parseInt(seg) / 1000;
}
usToMs += msToMs + sToMs;
return usToMs;
}
function toUS(input) {
return toMS(input) * 1000;
}
If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.