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.
33 lines
688 B
33 lines
688 B
function isEmpty(val) {
|
|
return typeof val === 'undefined' || val === '' || val === null
|
|
}
|
|
|
|
function formateDate(datetime) {
|
|
if (isEmpty(datetime)) {
|
|
return ''
|
|
}
|
|
var date = getDate(datetime.trim())
|
|
var today = getDate()
|
|
var week = ''
|
|
if (date.toString().substring(0, 15) === today.toString().substring(0, 15)) {
|
|
week = '(今天)'
|
|
} else if (date.getTime() > today.getTime()) {
|
|
week = '(明天)'
|
|
}
|
|
return week + datetime
|
|
}
|
|
|
|
function formateText(text, length) {
|
|
if (!text) {
|
|
return ''
|
|
}
|
|
if (text.length <= length) {
|
|
return text
|
|
}
|
|
return text.substring(0, length)
|
|
}
|
|
|
|
module.exports = {
|
|
formateDate: formateDate,
|
|
formateText: formateText
|
|
}
|