const uptime_pattern = /(?:(\d+)\s+days?,\s+)?(\d+):(\d+):(\d+)/;

const match = value.match(uptime_pattern);

if (match) {
	const days = parseInt(match[1] || "0", 10),
		  hours = parseInt(match[2], 10),
		  minutes = parseInt(match[3], 10),
		  seconds = parseInt(match[4], 10);

	return days * 86400 + hours * 3600 + minutes * 60 + seconds;
} else {
	throw 'Incorrect uptime string received: ' + value + '. Expected format: D days, HH:mm:ss';
}