How to use the iso8601-duration.parse function in iso8601-duration

To help you get started, we’ve selected a few iso8601-duration 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 paed01 / bpmn-engine / lib / eventDefinitions / TimerEventDefinition.js View on Github external
function isoToMs(isoDuration) {
    return toSeconds(parse(isoDuration)) * 1000;
  }
};
github serverless / enterprise-plugin / lib / safeguards / policies / restricted-deploy-times.js View on Github external
module.exports = function restrictedDeployTimesPolicy(policy, service, options = []) {
  const now = moment();

  for (let { time, duration, interval } of Array.isArray(options) ? options : [options]) {
    time = moment(time);
    duration = moment.duration(parse(duration));
    interval = interval && moment.duration(parse(interval));

    while (time.isBefore(now)) {
      const end = time.clone();
      end.add(duration);
      if (end.isAfter(now)) {
        policy.fail(`Deploying on ${now.format('YYYY-MM-DD')} is not allowed`);
        return;
      }
      if (interval) {
        time.add(interval);
      } else {
        break;
      }
    }
  }
github serverless / enterprise-plugin / lib / safeguards / policies / restricted-deploy-times.js View on Github external
module.exports = function restrictedDeployTimesPolicy(policy, service, options = []) {
  const now = moment();

  for (let { time, duration, interval } of Array.isArray(options) ? options : [options]) {
    time = moment(time);
    duration = moment.duration(parse(duration));
    interval = interval && moment.duration(parse(interval));

    while (time.isBefore(now)) {
      const end = time.clone();
      end.add(duration);
      if (end.isAfter(now)) {
        policy.fail(`Deploying on ${now.format('YYYY-MM-DD')} is not allowed`);
        return;
      }
      if (interval) {
        time.add(interval);
      } else {
        break;
      }
    }
  }
  policy.approve();

iso8601-duration

Node/Js-module for parsing and making sense of ISO8601-durations

MIT
Latest version published 5 months ago

Package Health Score

72 / 100
Full package analysis

Popular iso8601-duration functions