import moment from 'moment'
import { getFormatDatetime } from "@/utils/date";

export const shortcuts = [
    {
        text: '今天',
        value: (() => {
            let start = new Date()
            return [getFormatDatetime(start, 'YYYY-MM-DD'), getFormatDatetime(start, 'YYYY-MM-DD')]
        })(),
    },
    {
        text: '最近一周',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            return [start, end]
        })(),
    },
    {
        text: '最近一个月',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            return [start, end]
        })(),
    },
    {
        text: '最近三个月',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            return [start, end]
        })(),
    },
]

export const clockinShortcuts = [
    {
        text: '上一个月',
        value: (() => {
            const start = moment(moment().month(moment().month() - 1).startOf('month').valueOf()).format('YYYY-MM-DD');
            const end = moment(moment().month(moment().month() - 1).endOf('month').valueOf()).format('YYYY-MM-DD');
            return [start, end]
        })(),
    },
    {
        text: '本月',
        value: (() => {
            const start = moment(moment().month(moment().month()).startOf('month').valueOf()).format('YYYY-MM-DD')
            const end = new Date()
            return [start, end]
        })(),
    },
]

export const healthCardShortcuts = [
    {
        text: '最近三天',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 3)
            return [start, end]
        })(),
    },
    {
        text: '最近一周',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            return [start, end]
        })(),
    },
    {
        text: '最近一个月',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            return [start, end]
        })(),
    },
]

export const maxHalfYear = [
    {
        text: '最近一个月',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            return [start, end]
        })(),
    },
    {
        text: '最近三个月',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            return [start, end]
        })(),
    },
    {
        text: '最近半年',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 180)
            return [start, end]
        })(),
    },
]

export const setlShtcuts = [
    {
        text: '最近一周',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            return [start, end]
        })(),
    },
    {
        text: '最近半个月',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 15)
            return [start, end]
        })(),
    },
    {
        text: '最近一个月',
        value: (() => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            return [start, end]
        })(),
    },
]


export const seltYearAndNowLast = [
    {
        text: '第一个月',
        value: (() => {
            const now = new Date()
            const start = now.getFullYear() + "-01-01";
            const end = now.getFullYear() + "-01-31";
            return [start, end]
        })(),
    },
    {
        text: '上一个月',
        value: (() => {
            const nowDate = new Date()
            const month = nowDate.getMonth()
            // 如果是现在1月份，就取现在1月份的时间，否则取上一个月的时间
            if (month === 1) {
                const start = nowDate.getFullYear() + "-01-01";
                const end = nowDate.getFullYear() + "-01-31";
                return [start, end]
            } else {
                const start = moment(moment().month(moment().month() - 1).startOf('month').valueOf()).format('YYYY-MM-DD');
                const end = moment(moment().month(moment().month() - 1).endOf('month').valueOf()).format('YYYY-MM-DD');
                return [start, end]
            }
        })(),
    },
]
