How to use the cronstrue.toString function in cronstrue

To help you get started, we’ve selected a few cronstrue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plotly / falcon / app / components / Settings / cron-picker / cron-helpers.js View on Github external
export function mapCronToHourFormat(cronExpression) {
    try {
        cronstrue.toString(cronExpression);
    } catch (_) {
        return null;
    }

    const cronParts = cronExpression.split(' ');
    if (cronParts.length === 6) {
        // disregard seconds component
        cronParts.shift();
    }
    const [cronMinute, cronHour, cronDayOfMonth, cronMonth, cronDaysOfWeek] = cronParts;

    const time = {};
    time.minute = cronMinute.includes('*') ? 0 : Number(cronMinute);
    time.date = cronDayOfMonth.includes('*') ? 1 : Number(cronDayOfMonth);
    time.month = cronMonth.includes('*') ? 1 : Number(cronMonth);
    time.days = cronDaysOfWeek.includes('*') ? ['MON'] : cronDaysOfWeek.split(',');
github matt-deboer / kuill / pkg / ui / src / components / configuration-pane / ResourceDetails.js View on Github external
getData: ({status, spec, metadata }) => {
      return [
        ['Created:', `${metadata.creationTimestamp} ( ${toHumanizedAge(metadata.creationTimestamp)} ago )`],
        ['Schedule:', `${spec.schedule} ( ${cronstrue.toString(spec.schedule)} )`],
        ['Concurrency Policy:', spec.concurrencyPolicy],
        ['Suspend', spec.suspend],
        // ['Starting Deadline Seconds:', spec.startingDeadlineSeconds || ''],
        ['Selector:', (spec.selector && spec.selector.matchLabels) || ''],
        ['Parallelism:', spec.parallelism || ''],
        ['Last Schedule Time:', status.lastScheduleTime],
        //Completions:			 // => need to get details of owned Jobs for this...
      ]
    },
  },
github elastic / kibana / x-pack / legacy / plugins / rollup / public / crud_app / sections / job_create / steps_config / validate_rollup_cron.js View on Github external
export function validateRollupCron(rollupCron) {
  if (!rollupCron || !rollupCron.trim()) {
    return [
      ,
    ];
  }

  try {
    cronstrue.toString(rollupCron);
  } catch (error) {
    const prefix = 'Error: ';
    const prefixIndex = error.indexOf(prefix);

    // Note: cronstrue ships with a localizable version. Refer to the docs for more
    // info on how we can display a localized error value.
    return error.substring(prefixIndex + prefix.length);
  }

  return undefined;
}
github fusioncms / fusioncms / fusion / resources / js / components / CronScheduler.vue View on Github external
preview: function() {
				return this.manual ? 'Imports will run manually' : cronstrue.toString(this.expression)
			}
		},
github replicatedhq / kots / web / src / utilities / utilities.js View on Github external
export function getReadableCronDescriptor(expression) {
  return cronstrue.toString(expression);
}
github Zooz / predator / ui / src / features / utils.js View on Github external
export const getTimeFromCronExpr = (cronValue) => {
  let result;
  try {
    result = cronstrue.toString(cronValue)
  } catch (err) {
  }
  return result || ''
};
github dagster-io / dagster / js_modules / dagit / src / schedules / ScheduleRow.tsx View on Github external
const getNaturalLanguageCronString = (cronSchedule: string) => {
    try {
      return cronstrue.toString(cronSchedule);
    } catch {
      return "Invalid cron string";
    }
  };
github taskcluster / taskcluster / infrastructure / tooling / src / generate / generators / monitoring.js View on Github external
Object.entries(requirements[`procs-${name}`]).forEach(([proc, ext]) => {
        if (ext.type === 'cron') {
          res.push([name, proc, `taskcluster.${name}`, ext.deadline, cronstrue.toString(ext.schedule)]);
        }
        if (ext.type === 'background' && ext.subType === 'iterate') {
          res.push([name, proc, `taskcluster.${name}`, 'continuous', 'continuous']);
        }
      });
github Zooz / predator / ui / src / features / components / JobForm / validator.js View on Github external
function cronValidator (value, allState) {
  if (isRequired(value) && !allState.run_immediately) {
    return 'Required if run immediately is unchecked'
  }
  if(value){
    try {
      cronstrue.toString(value)
    } catch (err) {
      return 'illegal cron input'
    }
  }
}
function emailsValidator () {
github replicatedhq / kots / web / src / utilities / utilities.js View on Github external
export function getReadableCronDescriptor(expression) {
  if (expression == "@hourly") {
    expression = "0 * * * *"
  } else if (expression == "@daily") {
    expression = "0 0 * * *"
  } else if (expression == "@weekly") {
    expression = "0 0 * * 0"
  }
  return cronstrue.toString(expression);
}

cronstrue

Convert cron expressions into human readable descriptions

MIT
Latest version published 17 days ago

Package Health Score

86 / 100
Full package analysis

Popular cronstrue functions