function iso8601DurationToSeconds(iso8601Duration) {
	const iso8601DurationRegex = /(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?(?:T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?)?/;
	const matches = iso8601Duration.match(iso8601DurationRegex);

	duration = 0;
	matches.forEach( function (field, index) {
		if (field != undefined) {
			switch(index) {
				case 2: duration += parseInt(field) * daysInThisYear() * 86400; break;
				case 3: duration += parseInt(field) * daysInThisMonth() * 86400; break;
				case 4: duration += parseInt(field) * 604800; break;
				case 5: duration += parseInt(field) * 86400; break;
				case 6: duration += parseInt(field) * 3600; break;
				case 7: duration += parseInt(field) * 60; break;
				case 8: duration += parseInt(field);
			}
		}
	});

	return duration;
};

function daysInThisMonth() {
	const now = new Date();

	return new Date(now.getFullYear(), now.getMonth()+1, 0).getDate();
};

function daysInThisYear() {
	const now = new Date();

	return new Date(now.getFullYear(), 2, 0).getDate() + 337;
};

return iso8601DurationToSeconds(value);