export const timestampToTime = (timestamp) => {
    // 时间戳为10位需*1000，时间戳为13位不需乘1000
    var date = null
    if(timestamp.length<13){
      date= new Date(timestamp * 1000);
    }else{
      date= new Date(timestamp);
    }
    var Y = date.getFullYear() + "-";
    var M =
      (date.getMonth() + 1 < 10
        ? "0" + (date.getMonth() + 1)
        : date.getMonth() + 1) + "-";
    var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
    var h = date.getHours() + ":";
    var m = date.getMinutes() + ":";
    var s = date.getSeconds();
    return Y + M + D;
  }
  // 小时：分钟 ==》 转分钟
  
export const transFormMinut = (String) => {
    if(typeof(String) === 'number'){
        return
    }
    if(!String){
        return 0
    }
    let arr = String.split(':')
    let hour = arr[0].indexOf('0') === 0? arr[0].substring(1,arr[0].length):arr[0]
    let minu = arr[1].indexOf('0') === 0? arr[1].substring(1,arr[1].length):arr[1]
    return hour*60 + minu*1
}
// // 分钟 ==》 小时
export const transFormTime = (num) => {
    if (typeof(num) != 'string' && num !== 0) {
      return (Math.floor(num / 60)).toString() + ":" + (num % 60).toString()
    }
    else {
      return "0:00";
    }
}