﻿function fuzzyTime(oldts)
{
	if (oldts == '')return '';
	oldts = oldts * 1000 //javascript has 1000x mor eprecision
	var dte = new Date();
	var tOld = new Date(oldts)
	var tNow = dte.getTime();
	var tDiff = tNow - tOld //difference in microseconds is here;
	tDiff = tDiff /1000; //seconds
	
	tDiff = tDiff /60 ; //minutes
	if (tDiff<5)	return ('teraz');//under one hour
	
	if (tDiff<60)	return (Math.floor(tDiff) + '&nbsp;min.');//under one hour
	
	tDiff = tDiff /60 ; //hours
	if (tDiff < 24)	return (Math.floor(tDiff) + '&nbsp;hod.');//under one day
	
	tDiff = Math.floor(tDiff / 24); //days	
	if (tDiff < 2)	return (tDiff + '&nbsp;deň');	
	if (tDiff < 5)	return (tDiff + '&nbsp;dni');	
	if (tDiff < 8)	return (tDiff + '&nbsp;dní');	
	
	if (tDiff < 32)	return (Math.floor(tDiff/7) + '&nbsp;týž.');
	if (tDiff < 366)return (Math.floor(tDiff/31) + '&nbsp;mes.');
	
	tDiff = Math.floor(tDiff/365);
	if (tDiff<2)	return (tDiff + '&nbsp;rok');
	if (tDiff<4)	return (tDiff + '&nbsp;roky');
	
	return (tDiff + '&nbsp;rokov');	
}
function mkft(oldts)
{
	document.write(fuzzyTime(oldts));
}
