( startDate: ConfigType, endDate: ConfigType )
| 8 | export type DateUnit = 'minute' | 'hour' | 'day' | 'month' | 'year'; |
| 9 | |
| 10 | export function getMinimumUnit( |
| 11 | startDate: ConfigType, |
| 12 | endDate: ConfigType |
| 13 | ): DateUnit { |
| 14 | if (dayjs(endDate).diff(startDate, 'minutes') <= 60) { |
| 15 | return 'minute'; |
| 16 | } else if (dayjs(endDate).diff(startDate, 'hours') <= 48) { |
| 17 | return 'hour'; |
| 18 | } else if (dayjs(endDate).diff(startDate, 'days') <= 90) { |
| 19 | return 'day'; |
| 20 | } else if (dayjs(endDate).diff(startDate, 'months') <= 24) { |
| 21 | return 'month'; |
| 22 | } |
| 23 | |
| 24 | return 'year'; |
| 25 | } |
| 26 | |
| 27 | function createDateUnitFn(unit: DateUnit, timezone?: string) { |
| 28 | if (timezone) { |
no outgoing calls
no test coverage detected