You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
const formatTime = date => {
|
|
const year = date.getFullYear()
|
|
const month = date.getMonth() + 1
|
|
const day = date.getDate()
|
|
const hour = date.getHours()
|
|
const minute = date.getMinutes()
|
|
const second = date.getSeconds()
|
|
|
|
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
|
}
|
|
const formatTimestamp = date => {
|
|
const year = date.getFullYear()
|
|
const month = date.getMonth() + 1
|
|
const day = date.getDate()
|
|
const hour = date.getHours()
|
|
const minute = date.getMinutes()
|
|
const second = date.getSeconds()
|
|
|
|
return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
|
}
|
|
|
|
const formatTimeOpen = (date, spe1, spe2) => {
|
|
const year = date.getFullYear()
|
|
const month = date.getMonth() + 1
|
|
const day = date.getDate()
|
|
const hour = date.getHours()
|
|
const minute = date.getMinutes()
|
|
const second = date.getSeconds()
|
|
|
|
return [year, month, day].map(formatNumber).join(spe1) + ' ' + [hour, minute, second].map(formatNumber).join(spe2)
|
|
}
|
|
|
|
|
|
|
|
const formatNumber = n => {
|
|
n = n.toString()
|
|
return n[1] ? n : '0' + n
|
|
}
|
|
const substr = val => {
|
|
if (val.length == 0 || val == undefined) {
|
|
return false;
|
|
} else if (val.length > 12) {
|
|
return val.substring(0, 12) + "...";
|
|
} else {
|
|
return val;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
formatTime: formatTime,
|
|
substr: substr,
|
|
formatTimeOpen: formatTimeOpen,
|
|
formatTimestamp: formatTimestamp
|
|
|
|
}
|
|
|