|
|
@ -1,20 +1,20 @@ |
|
|
import dayjs from 'dayjs'; |
|
|
import dayjs from 'dayjs'; |
|
|
|
|
|
|
|
|
const advancedFormat = require('dayjs/plugin/advancedFormat'); |
|
|
// const advancedFormat = require('dayjs/plugin/advancedFormat');
|
|
|
const weekOfYear = require('dayjs/plugin/weekOfYear'); |
|
|
// const weekOfYear = require('dayjs/plugin/weekOfYear');
|
|
|
const duration = require('dayjs/plugin/duration'); |
|
|
// const duration = require('dayjs/plugin/duration');
|
|
|
|
|
|
|
|
|
dayjs.extend(advancedFormat); |
|
|
// dayjs.extend(advancedFormat);
|
|
|
dayjs.extend(weekOfYear); |
|
|
// dayjs.extend(weekOfYear);
|
|
|
dayjs.extend(duration); |
|
|
// dayjs.extend(duration);
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 格式化数字 |
|
|
* 格式化数字 |
|
|
* @param {*} n |
|
|
* @param {*} n |
|
|
*/ |
|
|
*/ |
|
|
const formatNumber = n => { |
|
|
const formatNumber = n => { |
|
|
const str = n.toString(); |
|
|
const str = n.toString(); |
|
|
return str[1] ? str : `0${str}`; |
|
|
return str[1] ? str : `0${str}`; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -22,15 +22,15 @@ const formatNumber = n => { |
|
|
* @param {number} beginTime |
|
|
* @param {number} beginTime |
|
|
*/ |
|
|
*/ |
|
|
const formatTime = beginTime => { |
|
|
const formatTime = beginTime => { |
|
|
const date = new Date(beginTime); |
|
|
const date = new Date(beginTime); |
|
|
const year = date.getFullYear(); |
|
|
const year = date.getFullYear(); |
|
|
const month = date.getMonth() + 1; |
|
|
const month = date.getMonth() + 1; |
|
|
const day = date.getDate(); |
|
|
const day = date.getDate(); |
|
|
const hour = date.getHours(); |
|
|
const hour = date.getHours(); |
|
|
const minute = date.getMinutes(); |
|
|
const minute = date.getMinutes(); |
|
|
const second = date.getSeconds(); |
|
|
const second = date.getSeconds(); |
|
|
|
|
|
|
|
|
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`; |
|
|
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -40,8 +40,8 @@ const formatTime = beginTime => { |
|
|
* @param {string} cycle |
|
|
* @param {string} cycle |
|
|
*/ |
|
|
*/ |
|
|
const add = (time, num, cycle) => { |
|
|
const add = (time, num, cycle) => { |
|
|
const str = dayjs(time).add(num, cycle); |
|
|
const str = dayjs(time).add(num, cycle); |
|
|
return str; |
|
|
return str; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -50,11 +50,11 @@ const add = (time, num, cycle) => { |
|
|
* @returns {{hours: number, minutes: number}} |
|
|
* @returns {{hours: number, minutes: number}} |
|
|
*/ |
|
|
*/ |
|
|
const convertTime = time => { |
|
|
const convertTime = time => { |
|
|
const arr = time.split(':'); |
|
|
const arr = time.split(':'); |
|
|
return { |
|
|
return { |
|
|
hours: parseInt(arr[0], 10), |
|
|
hours: parseInt(arr[0], 10), |
|
|
minutes: parseInt(arr[1], 10), |
|
|
minutes: parseInt(arr[1], 10), |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -62,12 +62,12 @@ const convertTime = time => { |
|
|
* @param {number} seconds |
|
|
* @param {number} seconds |
|
|
*/ |
|
|
*/ |
|
|
const secondToMinute = seconds => { |
|
|
const secondToMinute = seconds => { |
|
|
const minute = formatNumber(Math.floor(seconds / 60)); |
|
|
const minute = formatNumber(Math.floor(seconds / 60)); |
|
|
const second = formatNumber(parseInt(seconds % 60, 10)); |
|
|
const second = formatNumber(parseInt(seconds % 60, 10)); |
|
|
return { |
|
|
return { |
|
|
minute, |
|
|
minute, |
|
|
second, |
|
|
second, |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -76,18 +76,18 @@ const secondToMinute = seconds => { |
|
|
* @return date:2018/10/09 time: 12:59 |
|
|
* @return date:2018/10/09 time: 12:59 |
|
|
*/ |
|
|
*/ |
|
|
const setTimestampToStr = timestamp => { |
|
|
const setTimestampToStr = timestamp => { |
|
|
const timeObj = new Date(timestamp); |
|
|
const timeObj = new Date(timestamp); |
|
|
const year = timeObj.getFullYear(); |
|
|
const year = timeObj.getFullYear(); |
|
|
const month = formatNumber(timeObj.getMonth() + 1); |
|
|
const month = formatNumber(timeObj.getMonth() + 1); |
|
|
const day = formatNumber(timeObj.getDate()); |
|
|
const day = formatNumber(timeObj.getDate()); |
|
|
const hour = formatNumber(timeObj.getHours()); |
|
|
const hour = formatNumber(timeObj.getHours()); |
|
|
const minute = formatNumber(timeObj.getMinutes()); |
|
|
const minute = formatNumber(timeObj.getMinutes()); |
|
|
const date = `${year}-${month}-${day}`; |
|
|
const date = `${year}-${month}-${day}`; |
|
|
const time = `${hour}:${minute}`; |
|
|
const time = `${hour}:${minute}`; |
|
|
return { |
|
|
return { |
|
|
date, |
|
|
date, |
|
|
time, |
|
|
time, |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -95,9 +95,10 @@ const setTimestampToStr = timestamp => { |
|
|
* @param {Number} time 时间戳 |
|
|
* @param {Number} time 时间戳 |
|
|
*/ |
|
|
*/ |
|
|
const validateTimeIsToday = time => { |
|
|
const validateTimeIsToday = time => { |
|
|
const timeDate = new Date(time); |
|
|
const timeDate = new Date(time); |
|
|
const date = new Date(); |
|
|
const date = new Date(); |
|
|
return timeDate.getFullYear() === date.getFullYear() && timeDate.getMonth() === date.getMonth() && timeDate.getDate() === date.getDate(); |
|
|
return timeDate.getFullYear() === date.getFullYear() && timeDate.getMonth() === date.getMonth() && timeDate |
|
|
|
|
|
.getDate() === date.getDate(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -107,8 +108,8 @@ const validateTimeIsToday = time => { |
|
|
* @param {string} cycle 传入 day 将会比较 day、 month和 year |
|
|
* @param {string} cycle 传入 day 将会比较 day、 month和 year |
|
|
*/ |
|
|
*/ |
|
|
const isSame = (time, value, cycle) => { |
|
|
const isSame = (time, value, cycle) => { |
|
|
const str = dayjs(time).isSame(value, cycle); |
|
|
const str = dayjs(time).isSame(value, cycle); |
|
|
return str; |
|
|
return str; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -120,25 +121,25 @@ const isSame = (time, value, cycle) => { |
|
|
* 否则 *月*日 时:分 |
|
|
* 否则 *月*日 时:分 |
|
|
*/ |
|
|
*/ |
|
|
const formatBeginTime = timestamp => { |
|
|
const formatBeginTime = timestamp => { |
|
|
const timeObj = new Date(timestamp); |
|
|
const timeObj = new Date(timestamp); |
|
|
const year = timeObj.getFullYear(); |
|
|
const year = timeObj.getFullYear(); |
|
|
const month = formatNumber(timeObj.getMonth() + 1); |
|
|
const month = formatNumber(timeObj.getMonth() + 1); |
|
|
const day = formatNumber(timeObj.getDate()); |
|
|
const day = formatNumber(timeObj.getDate()); |
|
|
const hour = formatNumber(timeObj.getHours()); |
|
|
const hour = formatNumber(timeObj.getHours()); |
|
|
const minute = formatNumber(timeObj.getMinutes()); |
|
|
const minute = formatNumber(timeObj.getMinutes()); |
|
|
const date = `${year}/${month}/${day}`; |
|
|
const date = `${year}/${month}/${day}`; |
|
|
const time = `${hour}:${minute}`; |
|
|
const time = `${hour}:${minute}`; |
|
|
const currentYear = new Date().getFullYear(); |
|
|
const currentYear = new Date().getFullYear(); |
|
|
|
|
|
|
|
|
if (validateTimeIsToday(timestamp)) { |
|
|
if (validateTimeIsToday(timestamp)) { |
|
|
// 今天
|
|
|
// 今天
|
|
|
return `今天 ${time}`; |
|
|
return `今天 ${time}`; |
|
|
} else if (currentYear !== year) { |
|
|
} else if (currentYear !== year) { |
|
|
// 不是今年
|
|
|
// 不是今年
|
|
|
return `${date} ${time}`; |
|
|
return `${date} ${time}`; |
|
|
} else { |
|
|
} else { |
|
|
return `${month}月${day}日 ${time}`; |
|
|
return `${month}月${day}日 ${time}`; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -150,42 +151,42 @@ const formatBeginTime = timestamp => { |
|
|
* 超过2小时( 2 * 60 * 60 * 1000 ms) 转换成小时 + 分钟数 |
|
|
* 超过2小时( 2 * 60 * 60 * 1000 ms) 转换成小时 + 分钟数 |
|
|
*/ |
|
|
*/ |
|
|
const formatDuration = duration => { |
|
|
const formatDuration = duration => { |
|
|
const minuteTime = 60 * 1000; |
|
|
const minuteTime = 60 * 1000; |
|
|
const hourTime = 60 * minuteTime; |
|
|
const hourTime = 60 * minuteTime; |
|
|
const dayTime = 24 * hourTime; |
|
|
const dayTime = 24 * hourTime; |
|
|
const days = Math.floor(duration / dayTime); |
|
|
const days = Math.floor(duration / dayTime); |
|
|
const hours = Math.floor((duration % dayTime) / hourTime); |
|
|
const hours = Math.floor((duration % dayTime) / hourTime); |
|
|
const minutes = Math.floor((duration % hourTime) / minuteTime); |
|
|
const minutes = Math.floor((duration % hourTime) / minuteTime); |
|
|
if (duration <= 60 * 1000) { |
|
|
if (duration <= 60 * 1000) { |
|
|
// 小于1分钟 返回几秒
|
|
|
// 小于1分钟 返回几秒
|
|
|
return `${Math.floor(duration / 1000)}秒`; |
|
|
return `${Math.floor(duration / 1000)}秒`; |
|
|
} else if (duration > dayTime) { |
|
|
} else if (duration > dayTime) { |
|
|
// 大于1天
|
|
|
// 大于1天
|
|
|
if (minutes === 0) { |
|
|
if (minutes === 0) { |
|
|
if (hours === 0) { |
|
|
if (hours === 0) { |
|
|
// 分钟数是0 和 小时数是0 返回 几天
|
|
|
// 分钟数是0 和 小时数是0 返回 几天
|
|
|
return `${days}天`; |
|
|
return `${days}天`; |
|
|
} else { |
|
|
} else { |
|
|
// 分钟是0 小时不是0 返回 几天几小时
|
|
|
// 分钟是0 小时不是0 返回 几天几小时
|
|
|
return `${days}天${hours}小时`; |
|
|
return `${days}天${hours}小时`; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
// 分钟不是0 返回几天几时几分
|
|
|
// 分钟不是0 返回几天几时几分
|
|
|
return `${days}天${hours}时${minutes}分`; |
|
|
return `${days}天${hours}时${minutes}分`; |
|
|
} |
|
|
} |
|
|
} else if (duration > 2 * hourTime) { |
|
|
} else if (duration > 2 * hourTime) { |
|
|
// 大于2h
|
|
|
// 大于2h
|
|
|
if (minutes === 0) { |
|
|
if (minutes === 0) { |
|
|
// 分钟是0 返回几小时
|
|
|
// 分钟是0 返回几小时
|
|
|
return `${hours}小时`; |
|
|
return `${hours}小时`; |
|
|
} else { |
|
|
} else { |
|
|
// 分钟不是0 返回几小时几分钟
|
|
|
// 分钟不是0 返回几小时几分钟
|
|
|
return `${hours}小时${minutes}分钟`; |
|
|
return `${hours}小时${minutes}分钟`; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
// 其余情况 返回 几分钟
|
|
|
// 其余情况 返回 几分钟
|
|
|
return `${parseInt(duration / minuteTime)}分钟`; |
|
|
return `${parseInt(duration / minuteTime)}分钟`; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -197,53 +198,53 @@ const formatDuration = duration => { |
|
|
* 超过2小时( 2 * 60 * 60 * 1000 ms) 转换成{ days: 0, hours, minutes, seconds: 0 } |
|
|
* 超过2小时( 2 * 60 * 60 * 1000 ms) 转换成{ days: 0, hours, minutes, seconds: 0 } |
|
|
*/ |
|
|
*/ |
|
|
const formatDurationToObject = duration => { |
|
|
const formatDurationToObject = duration => { |
|
|
const minuteTime = 60 * 1000; |
|
|
const minuteTime = 60 * 1000; |
|
|
const hourTime = 60 * minuteTime; |
|
|
const hourTime = 60 * minuteTime; |
|
|
const dayTime = 24 * hourTime; |
|
|
const dayTime = 24 * hourTime; |
|
|
const days = Math.floor(duration / dayTime); |
|
|
const days = Math.floor(duration / dayTime); |
|
|
const hours = Math.floor((duration % dayTime) / hourTime); |
|
|
const hours = Math.floor((duration % dayTime) / hourTime); |
|
|
const minutes = Math.floor((duration % hourTime) / minuteTime); |
|
|
const minutes = Math.floor((duration % hourTime) / minuteTime); |
|
|
const result = { |
|
|
const result = { |
|
|
days: 0, |
|
|
days: 0, |
|
|
hours: 0, |
|
|
hours: 0, |
|
|
minutes: 0, |
|
|
minutes: 0, |
|
|
seconds: 0, |
|
|
seconds: 0, |
|
|
}; |
|
|
}; |
|
|
if (duration <= 60 * 1000) { |
|
|
if (duration <= 60 * 1000) { |
|
|
// 小于1分钟 返回几秒
|
|
|
// 小于1分钟 返回几秒
|
|
|
result.seconds = Math.floor(duration / 1000); |
|
|
result.seconds = Math.floor(duration / 1000); |
|
|
} else if (duration > dayTime) { |
|
|
} else if (duration > dayTime) { |
|
|
// 大于1天
|
|
|
// 大于1天
|
|
|
if (minutes === 0) { |
|
|
if (minutes === 0) { |
|
|
if (hours === 0) { |
|
|
if (hours === 0) { |
|
|
// 分钟数是0 和 小时数是0 返回 几天
|
|
|
// 分钟数是0 和 小时数是0 返回 几天
|
|
|
result.days = days; |
|
|
result.days = days; |
|
|
} else { |
|
|
} else { |
|
|
// 分钟是0 小时不是0 返回 几天几小时
|
|
|
// 分钟是0 小时不是0 返回 几天几小时
|
|
|
result.days = days; |
|
|
result.days = days; |
|
|
result.hours = hours; |
|
|
result.hours = hours; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
// 分钟不是0 返回几天几时几分
|
|
|
// 分钟不是0 返回几天几时几分
|
|
|
result.days = days; |
|
|
result.days = days; |
|
|
result.hours = hours; |
|
|
result.hours = hours; |
|
|
result.minutes = minutes; |
|
|
result.minutes = minutes; |
|
|
} |
|
|
} |
|
|
} else if (duration > 2 * hourTime) { |
|
|
} else if (duration > 2 * hourTime) { |
|
|
// 大于2h
|
|
|
// 大于2h
|
|
|
if (minutes === 0) { |
|
|
if (minutes === 0) { |
|
|
// 分钟是0 返回几小时
|
|
|
// 分钟是0 返回几小时
|
|
|
result.hours = hours; |
|
|
result.hours = hours; |
|
|
} else { |
|
|
} else { |
|
|
// 分钟不是0 返回几小时几分钟
|
|
|
// 分钟不是0 返回几小时几分钟
|
|
|
result.hours = hours; |
|
|
result.hours = hours; |
|
|
result.minutes = minutes; |
|
|
result.minutes = minutes; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
// 其余情况 返回 几分钟
|
|
|
// 其余情况 返回 几分钟
|
|
|
result.minutes = minutes; |
|
|
result.minutes = minutes; |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -252,7 +253,7 @@ const formatDurationToObject = duration => { |
|
|
* @return 时长的ms |
|
|
* @return 时长的ms |
|
|
*/ |
|
|
*/ |
|
|
const formatObjectTimeToMs = (days = 0, hours = 0, minutes = 0, seconds = 0) => { |
|
|
const formatObjectTimeToMs = (days = 0, hours = 0, minutes = 0, seconds = 0) => { |
|
|
return days * 24 * 60 * 60 * 1000 + hours * 60 * 60 * 1000 + minutes * 60 * 1000 + seconds * 1000; |
|
|
return days * 24 * 60 * 60 * 1000 + hours * 60 * 60 * 1000 + minutes * 60 * 1000 + seconds * 1000; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -261,23 +262,23 @@ const formatObjectTimeToMs = (days = 0, hours = 0, minutes = 0, seconds = 0) => |
|
|
* @return {string} cycle 周期英文字符串 |
|
|
* @return {string} cycle 周期英文字符串 |
|
|
*/ |
|
|
*/ |
|
|
const computeCycle = time => { |
|
|
const computeCycle = time => { |
|
|
// 加载下一个周期的任务
|
|
|
// 加载下一个周期的任务
|
|
|
let cycle = 'day'; |
|
|
let cycle = 'day'; |
|
|
switch (time) { |
|
|
switch (time) { |
|
|
case '天': |
|
|
case '天': |
|
|
cycle = 'day'; |
|
|
cycle = 'day'; |
|
|
break; |
|
|
break; |
|
|
case '周': |
|
|
case '周': |
|
|
cycle = 'week'; |
|
|
cycle = 'week'; |
|
|
break; |
|
|
break; |
|
|
case '月': |
|
|
case '月': |
|
|
cycle = 'month'; |
|
|
cycle = 'month'; |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
cycle = '日程'; |
|
|
cycle = '日程'; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
return cycle; |
|
|
return cycle; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -286,26 +287,26 @@ const computeCycle = time => { |
|
|
* @param {number|string} time 时间 |
|
|
* @param {number|string} time 时间 |
|
|
*/ |
|
|
*/ |
|
|
const formatStartTimeToCycleTime = (cycle, time) => { |
|
|
const formatStartTimeToCycleTime = (cycle, time) => { |
|
|
let result = ''; |
|
|
let result = ''; |
|
|
const _time = dayjs(+time); |
|
|
const _time = dayjs(+time); |
|
|
switch (cycle) { |
|
|
switch (cycle) { |
|
|
case '天': |
|
|
case '天': |
|
|
result = _time.format('YYYY年M月D日'); |
|
|
result = _time.format('YYYY年M月D日'); |
|
|
break; |
|
|
break; |
|
|
case '周': |
|
|
case '周': |
|
|
result = _time.format('YYYY年w周'); |
|
|
result = _time.format('YYYY年w周'); |
|
|
break; |
|
|
break; |
|
|
case '月': |
|
|
case '月': |
|
|
result = _time.format('YYYY年M月'); |
|
|
result = _time.format('YYYY年M月'); |
|
|
break; |
|
|
break; |
|
|
case '日程': |
|
|
case '日程': |
|
|
result = _time.format('YYYY年M月D日 HH:mm'); |
|
|
result = _time.format('YYYY年M月D日 HH:mm'); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
result = _time.format('YYYY年M月D日'); |
|
|
result = _time.format('YYYY年M月D日'); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -314,53 +315,70 @@ const formatStartTimeToCycleTime = (cycle, time) => { |
|
|
* @returns { num: 显示的数字, time: 演示器演示时长 } |
|
|
* @returns { num: 显示的数字, time: 演示器演示时长 } |
|
|
*/ |
|
|
*/ |
|
|
const computeDurationText = leftTime => { |
|
|
const computeDurationText = leftTime => { |
|
|
try { |
|
|
try { |
|
|
if (leftTime < 0) return { num: 0, time: null }; |
|
|
if (leftTime < 0) return { |
|
|
const { years, months, days, hours, minutes, seconds, milliseconds } = dayjs.duration(leftTime).$d; |
|
|
num: 0, |
|
|
let num = 0; |
|
|
time: null |
|
|
let time = 1000; |
|
|
}; |
|
|
|
|
|
const { |
|
|
|
|
|
years, |
|
|
|
|
|
months, |
|
|
|
|
|
days, |
|
|
|
|
|
hours, |
|
|
|
|
|
minutes, |
|
|
|
|
|
seconds, |
|
|
|
|
|
milliseconds |
|
|
|
|
|
} = dayjs.duration(leftTime).$d; |
|
|
|
|
|
let num = 0; |
|
|
|
|
|
let time = 1000; |
|
|
|
|
|
|
|
|
if (years > 0) { |
|
|
if (years > 0) { |
|
|
num = years; |
|
|
num = years; |
|
|
time = 60 * 60 * 1000; // 按小时
|
|
|
time = 60 * 60 * 1000; // 按小时
|
|
|
} else if (months > 0) { |
|
|
} else if (months > 0) { |
|
|
num = months; |
|
|
num = months; |
|
|
time = 60 * 60 * 1000; // 按小时
|
|
|
time = 60 * 60 * 1000; // 按小时
|
|
|
} else if (days > 0) { |
|
|
} else if (days > 0) { |
|
|
num = days; |
|
|
num = days; |
|
|
time = 60 * 60 * 1000; // 按小时
|
|
|
time = 60 * 60 * 1000; // 按小时
|
|
|
} else if (hours > 0) { |
|
|
} else if (hours > 0) { |
|
|
num = hours; |
|
|
num = hours; |
|
|
} else if (minutes > 0) { |
|
|
} else if (minutes > 0) { |
|
|
num = minutes; |
|
|
num = minutes; |
|
|
} else if (seconds > 0) { |
|
|
} else if (seconds > 0) { |
|
|
num = seconds; |
|
|
num = seconds; |
|
|
} else if (milliseconds > 0) { |
|
|
} else if (milliseconds > 0) { |
|
|
num = milliseconds; |
|
|
num = milliseconds; |
|
|
time = 16; |
|
|
time = 16; |
|
|
} else { |
|
|
} else { |
|
|
time = null; |
|
|
time = null; |
|
|
} |
|
|
} |
|
|
return { num, time }; |
|
|
return { |
|
|
} catch (error) { |
|
|
num, |
|
|
console.log('🚀 ~ file: time.js ~ line 335 ~ computeDurationText ~ error', error); |
|
|
time |
|
|
return { num: 0, time: null }; |
|
|
}; |
|
|
} |
|
|
} catch (error) { |
|
|
|
|
|
console.log('🚀 ~ file: time.js ~ line 335 ~ computeDurationText ~ error', error); |
|
|
|
|
|
return { |
|
|
|
|
|
num: 0, |
|
|
|
|
|
time: null |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
formatNumber, |
|
|
formatNumber, |
|
|
formatTime, |
|
|
formatTime, |
|
|
add, |
|
|
add, |
|
|
convertTime, |
|
|
convertTime, |
|
|
secondToMinute, |
|
|
secondToMinute, |
|
|
setTimestampToStr, |
|
|
setTimestampToStr, |
|
|
isSame, |
|
|
isSame, |
|
|
formatBeginTime, |
|
|
formatBeginTime, |
|
|
formatDuration, |
|
|
formatDuration, |
|
|
formatDurationToObject, |
|
|
formatDurationToObject, |
|
|
formatObjectTimeToMs, |
|
|
formatObjectTimeToMs, |
|
|
computeCycle, |
|
|
computeCycle, |
|
|
formatStartTimeToCycleTime, |
|
|
formatStartTimeToCycleTime, |
|
|
computeDurationText, |
|
|
computeDurationText, |
|
|
}; |
|
|
}; |
|
|
|