zoukankan      html  css  js  c++  java
  • 天,小时,分钟的时间转换

    // 时间换算-x天x小时x分钟
    export function TimeFormat(value, hours = 8) {
        if (!value) {
            return '0天0小时0分钟';
        }
        const day = parseInt(value / 60 / hours, 10);
        const hour = parseInt((value / 60) % hours, 10);
        const min = parseInt(value % 60, 10);
        let newValue = '';
        if (day > 0) {
            newValue = `${day}天`;
        } else {
            newValue += ' 0天';
        }
        if (hour > 0) {
            newValue += `${hour}小时`;
        } else {
            newValue += '0小时';
        }
        if (min > 0) {
            newValue += `${parseFloat(min)}分钟`;
        } else {
            newValue += '0分钟';
        }
        return newValue;
    }
     
     
    // 一位小数小时
    // 时间换算-x小时
    export function TimeFormatHour(value) {
        const hour = parseFloat(value / 60, 10).toFixed(1);
        let newValue = '';
        if (hour > 0) {
            newValue += `${hour}小时`;
        }
        return newValue;
    }
  • 相关阅读:
    opencv源码编译安装后使用时出现undefined reference cv::imwrite
    OPPO手机永久打开USB调试模式
    bash 顺序执行等待前一个脚本执行完成
    cpp
    多线程
    关于nvme下ubuntu无法识别硬盘的问题
    极限建站
    新生赛
    pc_mbed_fpga_communication
    color_sensor_mbed
  • 原文地址:https://www.cnblogs.com/nangras/p/13261183.html
Copyright © 2011-2022 走看看