function dateToUTC(d8) {
    d8 = new Date(d8.toUTCString());
    return Date.UTC(d8.getFullYear(), d8.getMonth(), d8.getDate(),
            d8.getHours(), d8.getMinutes(), d8.getSeconds(),
            d8.getMilliseconds());
}
/* Today, yesterday, etc. */
function humanLastModified() {
    last_days = Math.floor(dateToUTC(new Date(document.lastModified)) / 86400000);
    now_days = Math.floor(dateToUTC(new Date()) / 86400000);
    days = now_days - last_days;
    amt = 0; unit = '';
    if (days >= 730) { // two years
        amt = Math.floor(days / 365); unit = 'years';
    }
    else if (days >= 365) { // one year
        amt = 1; unit = 'year';
    }
    else if (days >= 60) {
        amt = Math.floor(days / 30); unit = 'months';
    }
    else if (days >= 30) {
        amt = 1; unit = 'month';
    }
    else if (days >= 14) {
        amt = Math.floor(days / 7); unit = 'weeks';
    }
    else if (days >= 7) {
        amt = 1; unit = 'week';
    }
    else if (days > 1) {
        amt = 'a few'; unit = 'days';
    }

    if (unit != '') {
        return amt + ' ' + unit + ' ago';
    }
    else if (days == 1) {
        return '<em>yesterday</em>';
    }
    else {
        return '<em>today</em>';
    }
}

/* Gives an actual date */
var months = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
    'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
function lastModified() {
    var date = new Date(document.lastModified);
    return months[date.getMonth()] + ' ' + date.getDay() + ', ' +
        date.getFullYear();
}

