var timeUtil = {
    GetOfflineTimeStr: function(offlineTime, online) {
        if (online) return "在线";
        let now = Date.now();
        let dt = now - offlineTime;
        dt = Math.floor(dt);
        if (dt < 0) dt = 0;
        if (offlineTime == 0) return "离线(无记录)";
        let min = dt / (60 * 1000);
        min = Math.floor(min);
        if (min == 0) min += 1;
        if (min < 60) {
            return min + "分钟前";
        }
        let hour = min / 60;
        hour = Math.floor(hour);
        if (hour < 24) {
            return hour + "小时前";
        }
        let day = hour / 24;
        day = Math.floor(day);
        if (day < 365) {
            return day + "天前";
        }
        let year = day / 365;
        year = Map.floor(year);
        return year + "年前";
    },
    getDateStr: function(timestamp) {
        var date = timestamp === undefined ? new Date() : new Date(timestamp);
        var month = date.getMonth() + 1;
        var day = date.getDate();
        month = month < 10 ? ('0' + month) : month;
        day = day < 10 ? ('0' + day) : day;
        var dateStr = date.getFullYear() + '-' + month + '-' + day;
        return dateStr;
    }
}