| | |
| | | return dayjs(date).format(format) |
| | | } |
| | | |
| | | export function curDayStart() { |
| | | return dayjs().startOf('date').format(DATE_TIME_FORMAT) |
| | | } |
| | | |
| | | export function curDayEnd() { |
| | | return dayjs().endOf('date').format(DATE_TIME_FORMAT) |
| | | } |
| | | |
| | | export function formatTimestamp(_date: Date) { |
| | | return dayjs(_date).format("YYYY-MM-DD") |
| | | } |
| | | |
| | | export function calculateAge( _birthDay: Date) { |
| | | const birthday = dayjs(_birthDay); |
| | | const today = dayjs(new Date()); |
| | | return today.diff(birthday, 'year'); |
| | | } |
| | | |
| | | export function calculateHours( start: Date, end: Date) { |
| | | return dayjs(end).diff(dayjs(start), 'hour'); |
| | | } |
| | | |
| | | export function isCurrentDay( _date: Date) { |
| | | const today = dayjs(new Date()); |
| | | return today.isSame( dayjs(_date), 'day' ) |
| | | } |
| | | |
| | | export const dateUtil = dayjs |