|
@@ -0,0 +1,53 @@
|
|
|
+export function deepClone(obj) {
|
|
|
+ if (typeof obj !== 'object' || obj == null)
|
|
|
+ return obj
|
|
|
+
|
|
|
+ let res
|
|
|
+ if (Array.isArray(obj))
|
|
|
+ res = []
|
|
|
+
|
|
|
+ else
|
|
|
+ res = {}
|
|
|
+
|
|
|
+ for (const key in obj) {
|
|
|
+ if (obj.hasOwnProperty(key))
|
|
|
+ res[key] = deepClone(obj[key])
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|
|
|
+export function formatTime(time = Date.parse(new Date())) {
|
|
|
+ const date = new Date(Number(time))
|
|
|
+ const Y = `${date.getFullYear()}-`
|
|
|
+ const M
|
|
|
+ = `${date.getMonth() + 1 < 10
|
|
|
+ ? `0${date.getMonth() + 1}`
|
|
|
+ : date.getMonth() + 1}-`
|
|
|
+ const D
|
|
|
+ = date.getDate() < 10 ? `0${date.getDate()} ` : `${date.getDate()} `
|
|
|
+ const h
|
|
|
+ = date.getHours() < 10
|
|
|
+ ? `0${date.getHours()}:`
|
|
|
+ : `${date.getHours()}:`
|
|
|
+ const m
|
|
|
+ = date.getMinutes() < 10
|
|
|
+ ? `0${date.getMinutes()}:`
|
|
|
+ : `${date.getMinutes()}:`
|
|
|
+ const s
|
|
|
+ = date.getSeconds() < 10 ? `0${date.getSeconds()}` : date.getSeconds()
|
|
|
+ return Y + M + D + h + m + s
|
|
|
+}
|
|
|
+
|
|
|
+export function formatTimeToYMD(time) {
|
|
|
+ if (time === 'null000' || time === 'undefined000' || time === '000')
|
|
|
+ return ''
|
|
|
+
|
|
|
+ const date = new Date(Number(time))
|
|
|
+ const Y = `${date.getFullYear()}-`
|
|
|
+ const M
|
|
|
+ = `${date.getMonth() + 1 < 10
|
|
|
+ ? `0${date.getMonth() + 1}`
|
|
|
+ : date.getMonth() + 1}-`
|
|
|
+ const D
|
|
|
+ = date.getDate() < 10 ? `0${date.getDate()} ` : `${date.getDate()}`
|
|
|
+ return Y + M + D
|
|
|
+}
|