public/javascript/libs/jquery.easydate-0.2.4.js
function get_timeout_delay(date, settings)
    {
        var now = get_now();
        var diff = ((now.getTime() - date.getTime()) / 1000);
        var diff_abs = Math.abs(diff);
        
        if(isNaN(diff))
            return;
        
        var last_limit = 0;
        for(var i in settings.units)
        {
            var unit = settings.units[i];
            
            // Skip this unit if it's for past dates only and this is a future
            // date, or if it's for future dates only and this is a past date.
            if((unit.past_only && diff < 0) || (unit.future_only && diff > 0))
                continue;
            
            if(diff_abs < unit.limit)
            {
                // @todo: check edge cases (diff == 0)
                if(isNaN(unit.in_seconds))
                {
                    // This is not a real unit of time, so only update once we
                    // pass the limit of this unit.
                    if(diff < 0)
                        return (last_limit - diff_abs) * 1000 + 100;
                    else
                        return (unit.limit - diff_abs) * 1000 + 100;
                }
                else
                {
                    // Real unit of time - update every tick of this time unit.
                    if(diff < 0)
                        return (diff_abs % unit.in_seconds) * 1000 + 100
                    else
                        return (unit.in_seconds - (diff_abs % unit.in_seconds)) *
                            1000 + 100
                }
            }
            last_limit = unit.limit;
        }
        
        // Date is out of range of all units' limits. If this is a future date,
        // update once the date comes in range of a future unit.
        if(diff < 0)
        {
            for(var i = settings.units.length - 1; i >= 0; i--)
            {
                var unit = settings.units[i];
                
                if(unit.past_only)
                    continue;
                
                return (unit.limit - diff_abs) * 1000 + 100
            }
        }
    }
function get_timeout_delay(date, settings)
    {
        var now = get_now();
        var diff = ((now.getTime() - date.getTime()) / 1000);
        var diff_abs = Math.abs(diff);
        
        if(isNaN(diff))
            return;
        
        var last_limit = 0;
        for(var i in settings.units)
        {
            var unit = settings.units[i];
            
            // Skip this unit if it's for past dates only and this is a future
            // date, or if it's for future dates only and this is a past date.
            if((unit.past_only && diff < 0) || (unit.future_only && diff > 0))
                continue;
            
            if(diff_abs < unit.limit)
            {
                // @todo: check edge cases (diff == 0)
                if(isNaN(unit.in_seconds))
                {
                    // This is not a real unit of time, so only update once we
                    // pass the limit of this unit.
                    if(diff < 0)
                        return (last_limit - diff_abs) * 1000 + 100;
                    else
                        return (unit.limit - diff_abs) * 1000 + 100;
                }
                else
                {
                    // Real unit of time - update every tick of this time unit.
                    if(diff < 0)
                        return (diff_abs % unit.in_seconds) * 1000 + 100
                    else
                        return (unit.in_seconds - (diff_abs % unit.in_seconds)) *
                            1000 + 100
                }
            }
            last_limit = unit.limit;
        }
        
        // Date is out of range of all units' limits. If this is a future date,
        // update once the date comes in range of a future unit.
        if(diff < 0)
        {
            for(var i = settings.units.length - 1; i >= 0; i--)
            {
                var unit = settings.units[i];
                
                if(unit.past_only)
                    continue;
                
                return (unit.limit - diff_abs) * 1000 + 100
            }
        }
    }
Returns how long (in milliseconds) the timout until the next update for the given date should be.