utils.tsx 446 B

1234567891011121314151617181920
  1. import cronstrue from 'cronstrue';
  2. import {shouldUse24Hours} from 'sentry/utils/dates';
  3. export function crontabAsText(crontabInput: string | null): string | null {
  4. if (!crontabInput) {
  5. return null;
  6. }
  7. let parsedSchedule: string;
  8. try {
  9. parsedSchedule = cronstrue.toString(crontabInput, {
  10. verbose: true,
  11. use24HourTimeFormat: shouldUse24Hours(),
  12. });
  13. } catch (_e) {
  14. return null;
  15. }
  16. return parsedSchedule;
  17. }