react native常用方法整理(持续更新中 ... ):

1、关于时间戳转换日期:

const formatDate_t = (milliseconds, showWeek = true, showWeekMinute = true) => {
    if (!milliseconds) {
        return '-';
    }
    const date = new Date(milliseconds);
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const day = date.getDate();
    const hour = date.getHours(); // 0-23
    const minutes = date.getMinutes();
    const weekDay = date.getDay();

    const showMonth = month < 10 ? `0${month}` : month;
    const showDay = day < 10 ? `0${day}` : day;
    const showHour = hour < 10 ? `0${hour}` : hour;
    const showMinute = minutes < 10 ? `0${minutes}` : minutes;

    const weekDays = [0, 1, 2, 3, 4, 5, 6];
    const weekDayText = ['日', '一', '二', '三', '四', '五', '六'];

    if (!showWeekMinute) {
        return `${year}-${showMonth}-${showDay}`;
    }
    if (!showWeek) {
        return `${year}/${showMonth}/${showDay} ${showHour}:${showMinute}`;
    }
    return `${year}/${showMonth}/${showDay} 星期${weekDayText[weekDays.indexOf(weekDay)]} ${showHour}:${showMinute}`;
};

2、grunt命令配置Env文件:

grunt config

3、grunt命令更新模块版本号:

grunt updateVersion

你可能感兴趣的:(react native常用方法整理(持续更新中 ... ):)