| | |
| | | import dayjs from "dayjs"; |
| | | import dayjs from 'dayjs'; |
| | | |
| | | export default { |
| | | format(date, template) { |
| | | return dayjs(date).format(template) |
| | | return dayjs(date).format(template); |
| | | }, |
| | | |
| | | formatH(date){ |
| | | if (date) { |
| | | return this.format(date, 'HH:mm:ss') |
| | | return this.format(date, 'HH:mm:ss'); |
| | | } else { |
| | | return '--:--:--' |
| | | return '--:--:--'; |
| | | } |
| | | }, |
| | | |
| | | formatYM(date){ |
| | | if (date) { |
| | | return this.format(date, 'YYYY-MM') |
| | | return this.format(date, 'YYYY-MM'); |
| | | } else { |
| | | return '----/--' |
| | | return '----/--'; |
| | | } |
| | | }, |
| | | |
| | | formatYMD(date){ |
| | | if (date) { |
| | | return this.format(date, 'YYYY-MM-DD') |
| | | return this.format(date, 'YYYY-MM-DD'); |
| | | } else { |
| | | return '----/--/--' |
| | | return '----/--/--'; |
| | | } |
| | | }, |
| | | |
| | | formatYMDH(date){ |
| | | if (date) { |
| | | return this.format(date, 'YYYY-MM-DD HH:mm:ss') |
| | | return this.format(date, 'YYYY-MM-DD HH:mm:ss'); |
| | | } else { |
| | | return '----/--/-- --:--:--' |
| | | return '----/--/-- --:--:--'; |
| | | } |
| | | }, |
| | | |
| | | formatDateFromExcel(num, format) { |
| | | const old = num - 1; |
| | | const t = Math.round((old - Math.floor(old)) * 24 * 60 * 60); |
| | | const time = new Date(1900, 0, old, 0, 0, t); |
| | | const year = time.getFullYear(); |
| | | const month = time.getMonth() + 1; |
| | | const date = time.getDate(); |
| | | return ( |
| | | year + |
| | | format + |
| | | (month < 10 ? '0' + month : month) + |
| | | format + |
| | | (date < 10 ? '0' + date : date) |
| | | ); |
| | | } |
| | | }; |