var lang = {
        before: "prije",
        after: "za",
        seconds: ["jednu sekundu", "sekunde", "sekundi"],
        minutes: ["jednu minutu", "minute", "minuta"],
        hours: ["jedan sat", "sata", "sati"],
        days: ["jedan dan", "dana", "dana"],
        months: ["mjesec dana", "mjeseca", "mjeseci"],
        years: ["godinu dana", "godine", "godina"]
    };


    function letsGetFuzzy(date) {
        var diff = new Date().getTime() - new Date(date).getTime();

        var prefix = diff > 0 ? lang.before : lang.after;


        var seconds = Math.abs(diff) / 1000;
        var minutes = seconds / 60;
        var hours = minutes / 60;
        var days = hours / 24;
        var years = days / 365;


        var fuzzyTime = seconds < 45 && getPadez(lang.seconds, Math.round(seconds)) ||
                seconds < 90 && getPadez(lang.minutes, 1) ||
                minutes < 45 && getPadez(lang.minutes, Math.round(minutes)) ||
                minutes < 90 && getPadez(lang.hours, 1) ||
                hours < 24 && getPadez(lang.hours, Math.round(hours)) ||
                hours < 42 && getPadez(lang.days, 1) ||
                days < 30 && getPadez(lang.days, Math.round(days)) ||
                days < 45 && getPadez(lang.months, 1) ||
                days < 365 && getPadez(lang.months, Math.round(days / 30)) ||
                years < 1.5 && getPadez(lang.years, 1) ||
                getPadez(lang.years, Math.round(years));


        alert(prefix + " " + fuzzyTime);
    }


    function getPadez(jedinica, n) {
        if (n === 1) return jedinica[0];

        var n10, string;
        n10 = n % 10;

        if (n10 > 1 && n10 < 5 && (n > 20 || n < 10)) {
            string = jedinica[1];
        } else {
            string = jedinica[2];
        }

        return n + " " + string;
    }