( cronExpression: string | null, nextRunAt: string | null, lastRanAt: string | null, scheduleType?: string | null, timezone?: string | null )
| 669 | * Format schedule information for display |
| 670 | */ |
| 671 | export const getScheduleInfo = ( |
| 672 | cronExpression: string | null, |
| 673 | nextRunAt: string | null, |
| 674 | lastRanAt: string | null, |
| 675 | scheduleType?: string | null, |
| 676 | timezone?: string | null |
| 677 | ): { |
| 678 | scheduleTiming: string |
| 679 | nextRunFormatted: string | null |
| 680 | lastRunFormatted: string | null |
| 681 | } => { |
| 682 | if (!nextRunAt) { |
| 683 | return { |
| 684 | scheduleTiming: 'Unknown schedule', |
| 685 | nextRunFormatted: null, |
| 686 | lastRunFormatted: null, |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | let scheduleTiming = 'Unknown schedule' |
| 691 | |
| 692 | if (cronExpression) { |
| 693 | scheduleTiming = parseCronToHumanReadable(cronExpression, timezone || undefined) |
| 694 | } else if (scheduleType) { |
| 695 | scheduleTiming = `${scheduleType.charAt(0).toUpperCase() + scheduleType.slice(1)}` |
| 696 | } |
| 697 | |
| 698 | return { |
| 699 | scheduleTiming, |
| 700 | nextRunFormatted: formatDateTime(new Date(nextRunAt)), |
| 701 | lastRunFormatted: lastRanAt ? formatDateTime(new Date(lastRanAt)) : null, |
| 702 | } |
| 703 | } |
nothing calls this directly
no test coverage detected