/*
 * @Description: file content
 * @Version: 2.0
 * @Author: ljl
 * @Date: 2022-06-21 14:06:00
 * @LastEditors: ljl
 * @LastEditTime: 2022-06-22 11:33:19
 * @FilePath: \sui-shen-ban\src\mixins\format.js
 */
// export function getDate(date) {
//     let y = date.substring(0, 4)
//     let m = date.substring(4, 6)
//     let d = date.substring(6, 8)
//     return y + '-' + m + '-' + d
// }
// export function getTime(time) {
//     let h = time.substring(0, 2)
//     let m = time.substring(2, 4)
//     let s = time.substring(4, 6)
//     return h + ':' + m + ':' + s
// }
// export function getDateTime(datetime) {
//     let date = getDate(datetime.split('/')[0])
//     let time = getTime(datetime.split('/')[1])
//     return date + ' ' + time
// }

function getDate() {
    return {
        methods: {
            getDate(date) {
                let y = date.substring(0, 4)
                let m = date.substring(4, 6)
                let d = date.substring(6, 8)
                return y + '-' + m + '-' + d
            },
        },
    }
}
function getTime() {
    return {
        methods: {
            getTime(time) {
                let h = time.substring(0, 2)
                let m = time.substring(2, 4)
                let s = time.substring(4, 6)
                return h + ':' + m + ':' + s
            }
        },
    }
}
function getDateTime() {
    return {
        methods: {
            getDateTime(datetime) {
                // let date = datetime.split('/')[0]
                let date = datetime.substring(0, 8)
                let yyyy = date.substring(0, 4)
                let MM = date.substring(4, 6)
                let dd = date.substring(6, 8)
                // let time = datetime.split('/')[1]
                let time = datetime.substring(8,14)
                let HH = time.substring(0, 2)
                let mm = time.substring(2, 4)
                let ss = time.substring(4, 6)
                return yyyy + '-' + MM + '-' + dd + ' ' + HH + ':' + mm + ':' + ss
            }
        },
    }
}

export { getDate, getTime, getDateTime }