|
@@ -1,4 +1,4 @@
|
|
|
-function pluralize(time, label) {
|
|
|
+function pluralize (time, label) {
|
|
|
if (time === 1) {
|
|
|
return time + label
|
|
|
}
|
|
@@ -8,8 +8,7 @@ function pluralize(time, label) {
|
|
|
/**
|
|
|
* 日期格式化
|
|
|
*/
|
|
|
-export function dateFormat(date) {
|
|
|
- let format = 'yyyy-MM-dd hh:mm:ss'
|
|
|
+export function dateFormat (date, format = 'yyyy-MM-dd hh:mm:ss') {
|
|
|
if (date !== 'Invalid Date') {
|
|
|
var o = {
|
|
|
'M+': date.getMonth() + 1, // month
|
|
@@ -36,7 +35,7 @@ export function dateFormat(date) {
|
|
|
return ''
|
|
|
}
|
|
|
|
|
|
-export function timeAgo(time) {
|
|
|
+export function timeAgo (time) {
|
|
|
const between = Date.now() / 1000 - Number(time)
|
|
|
if (between < 3600) {
|
|
|
return pluralize(~~(between / 60), ' minute')
|
|
@@ -47,7 +46,7 @@ export function timeAgo(time) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export function parseTime(time, cFormat) {
|
|
|
+export function parseTime (time, cFormat) {
|
|
|
if (arguments.length === 0) {
|
|
|
return null
|
|
|
}
|
|
@@ -83,7 +82,7 @@ export function parseTime(time, cFormat) {
|
|
|
return time_str
|
|
|
}
|
|
|
|
|
|
-export function formatTime(time, option) {
|
|
|
+export function formatTime (time, option) {
|
|
|
time = +time * 1000
|
|
|
const d = new Date(time)
|
|
|
const now = Date.now()
|
|
@@ -107,7 +106,7 @@ export function formatTime(time, option) {
|
|
|
}
|
|
|
|
|
|
/* 数字 格式化 */
|
|
|
-export function nFormatter(num, digits) {
|
|
|
+export function nFormatter (num, digits) {
|
|
|
const si = [
|
|
|
{ value: 1E18, symbol: 'E' },
|
|
|
{ value: 1E15, symbol: 'P' },
|
|
@@ -124,12 +123,12 @@ export function nFormatter(num, digits) {
|
|
|
return num.toString()
|
|
|
}
|
|
|
|
|
|
-export function html2Text(val) {
|
|
|
+export function html2Text (val) {
|
|
|
const div = document.createElement('div')
|
|
|
div.innerHTML = val
|
|
|
return div.textContent || div.innerText
|
|
|
}
|
|
|
|
|
|
-export function toThousandslsFilter(num) {
|
|
|
+export function toThousandslsFilter (num) {
|
|
|
return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
|
|
|
}
|