MCPcopy Index your code
hub / github.com/simstudioai/sim / parseCronToHumanReadable

Function parseCronToHumanReadable

apps/sim/lib/workflows/schedules/utils.ts:513–536  ·  view source on GitHub ↗
(cronExpression: string, timezone?: string)

Source from the content-addressed store, hash-verified

511 * @returns Human-readable description of the schedule
512 */
513export const parseCronToHumanReadable = (cronExpression: string, timezone?: string): string => {
514 try {
515 const forDisplay = cronExpression.replace(/([0-7])#L\b/g, '$1L')
516 const baseDescription = cronstrue
517 .toString(forDisplay, {
518 use24HourTimeFormat: false,
519 verbose: false,
520 })
521 .replace(/\b0(\d:\d{2})/g, '$1')
522
523 if (timezone && timezone !== 'UTC') {
524 const tzAbbr = getTimezoneAbbreviation(timezone)
525 return `${baseDescription} (${tzAbbr})`
526 }
527
528 return baseDescription
529 } catch (error) {
530 logger.warn('Failed to parse cron expression with cronstrue:', {
531 cronExpression,
532 error: toError(error).message,
533 })
534 return `Schedule: ${cronExpression}${timezone && timezone !== 'UTC' ? ` (${getTimezoneAbbreviation(timezone)})` : ''}`
535 }
536}
537
538const REVERSE_DAY_MAP: Record<number, string> = {
539 0: 'SUN',

Callers 6

utils.test.tsFile · 0.90
performCreateJobFunction · 0.90
EmbeddedScheduledTaskFunction · 0.90
ScheduleInfoFunction · 0.90
useScheduleInfoFunction · 0.90
getScheduleInfoFunction · 0.85

Calls 5

toErrorFunction · 0.90
getTimezoneAbbreviationFunction · 0.70
replaceMethod · 0.65
warnMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected