Skip to content

Instantly share code, notes, and snippets.

View lukaszsagol's full-sized avatar
👁️‍🗨️

Łukasz Sągol lukaszsagol

👁️‍🗨️
View GitHub Profile
@lukaszsagol
lukaszsagol / period.js
Last active December 19, 2015 22:28 — forked from piecioshka/getPeriod.js
Additional support for parsing multiple periods in one string and adding them up (eg. "10h 30m")
function getPeriods(periods) {
var splittedPeriods = periods.match(/\d+(ms|s|m|h|d|o|y)/g);
var sum = 0;
splittedPeriods.forEach(function(period) {
sum += getPeriod(period);
});
return sum;
};