# 函数实现

const day = (day) => {
    let ret = '';
    switch (day) {
        case 0:
            ret = '';
            break;
        default:
            ret = `${day}`;
            break;
    }
    return ret;
};
const hour = (hour) => {
    let ret = '';
    switch (hour) {
        case 0:
            ret = '';
            break;
        default:
            ret = `${hour}小时`;
            break;
    }
    return ret;
};
const minute = (value) => {
    let ret = '';
    switch (value) {
        case 0:
            ret = '';
            break;
        default:
            ret = `${value}分钟`;
            break;
    }
    return ret;
};
const second = (second) => {
    let ret = '';
    switch (second) {
        case 0:
            ret = '';
            break;
        default:
            ret = `${second}`;
            break;
    }
    return ret;
};

let funEnums = {
    day: day,
    hour: hour,
    minute: minute,
    second: second,
};

let funUnion = ['day', 'hour', 'minute', 'second'];

const appendTimeUnit = (obj) => {
    if (!Object.keys(obj).length) {
        return '-';
    }
    let ret = '';
    for (var key in obj) {
        funUnion.includes(key) ? (ret = ret + funEnums[key](obj[key])) : (ret = ret);
    }
    return ret;
};

export default appendTimeUnit;

# 函数使用