|
|
@ -89,19 +89,20 @@ export const importAll = (context: any) => { |
|
|
* @returns {string} |
|
|
* @returns {string} |
|
|
*/ |
|
|
*/ |
|
|
export type Format = 'y.m.d' | 'y/m/d' | 'y-m-d' |
|
|
export type Format = 'y.m.d' | 'y/m/d' | 'y-m-d' |
|
|
export const formatDay = (date: Date, format: Format = 'y-m-d') => { |
|
|
|
|
|
|
|
|
export const formatDay = (format: Format = 'y-m-d') => { |
|
|
|
|
|
const date = new Date() |
|
|
const year = date.getFullYear() |
|
|
const year = date.getFullYear() |
|
|
|
|
|
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0') |
|
|
const month = String(date.getMonth() + 1).padStart(2, '0') |
|
|
const week = String(date.getDate()).padStart(2, '0') |
|
|
|
|
|
|
|
|
const day = String(date.getDate()).padStart(2, '0') |
|
|
|
|
|
|
|
|
if (format === 'y.m.d') { |
|
|
if (format === 'y.m.d') { |
|
|
return `${year}.${month}.${week}` |
|
|
|
|
|
|
|
|
return `${year}.${month}.${day}` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (format === 'y/m/d') { |
|
|
if (format === 'y/m/d') { |
|
|
return `${year}/${month}/${week}` |
|
|
|
|
|
|
|
|
return `${year}/${month}/${day}` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return year + '-' + month + '-' + week |
|
|
|
|
|
|
|
|
return year + '-' + month + '-' + day |
|
|
} |
|
|
} |
|
|
|