How to use the luxon.Duration.fromObject function in luxon

To help you get started, we’ve selected a few luxon 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 flow-typed / flow-typed / definitions / npm / luxon_v0.4.x / flow_v0.104.x- / test_luxon.js View on Github external
(dur.get("minutes"): number);
(dur.get("second"): number);
(dur.get("seconds"): number);
(dur.get("millisecond"): number);
(dur.get("milliseconds"): number);
// $ExpectError
(dur.get("date"): number);

(dur.inspect(): string);

(dur.negate(): Duration);
(dur.normalize(): Duration);

(dur.minus({ day: 1 }): Duration);
(dur.minus(232): Duration);
(dur.minus(Duration.fromObject({ day: 1 })): Duration);
// $ExpectError
(dur.minus({ glab: 1 }): Duration);

(dur.plus({ day: 1 }): Duration);
(dur.plus(232): Duration);
(dur.plus(Duration.fromObject({ day: 1 })): Duration);
// $ExpectError
(dur.plus({ glab: 1 }): Duration);

(dur.reconfigure({ locale: "de-DE" }): Duration);
(dur.reconfigure({ numberingSystem: "latn" }): Duration);
(dur.reconfigure({ conversionAccuracy: "longterm" }): Duration);
// $ExpectError
(dur.reconfigure({ foo: "bar" }): Duration);
// $ExpectError
(dur.reconfigure({ conversionAccuracy: "date" }): Duration);
github DefinitelyTyped / DefinitelyTyped / types / luxon / luxon-tests.ts View on Github external
DateTime.utc(); // $ExpectType DateTime
DateTime.local().toUTC(); // $ExpectType DateTime
DateTime.utc().toLocal(); // $ExpectType DateTime

DateTime.max(dt, now); // $ExpectType DateTime
DateTime.min(dt, now); // $ExpectType DateTime

const anything: any = 0;
if (DateTime.isDateTime(anything)) {
    anything; // $ExpectType DateTime
}

const { input, result, zone } = DateTime.fromFormatExplain('Aug 6 1982', 'MMMM d yyyy');

/* Duration */
const dur = Duration.fromObject({ hours: 2, minutes: 7 });
dt.plus(dur); // $ExpectType DateTime
dt.plus({ quarters: 2, month: 1 }); // $ExpectType DateTime
dur.hours; // $ExpectType number
dur.minutes; // $ExpectType number
dur.seconds; // $ExpectType number

dur.as('seconds'); // $ExpectType number
dur.toObject();
dur.toISO(); // $ExpectType string
dur.normalize(); // $ExpectType Duration
dur.mapUnits((x, u) => u === 'hours' ? x * 2 : x); // $ExpectType Duration

if (Duration.isDuration(anything)) {
    anything; // $ExpectType Duration
}
github Azure / BatchExplorer / src / app / components / job / action / add / job-preparation-task-picker.component.ts View on Github external
FormBuilder,
    NG_VALIDATORS,
    NG_VALUE_ACCESSOR,
    Validators,
} from "@angular/forms";
import { Duration } from "luxon";
import { JobTaskBaseComponent } from "./job-task-base.component";

const DEFAULT_JOBPREPARATION_ID = "jobpreparation";
const DEFAULT_JOBPREPARATION = {
    id: DEFAULT_JOBPREPARATION_ID,
    commandLine: "",
    waitForSuccess: true,
    rerunOnNodeRebootAfterSuccess: true,
    constraints: {
        retentionTime: Duration.fromObject({days: 7}),
    },
};
const INVALID_RESPONSE = {
    jobPreparationTaskPicker: {
        valid: false,
        missingSelection: true,
    },
};

@Component({
    selector: "bl-job-preparation-task-picker",
    templateUrl: "job-preparation-task-picker.html",
    providers: [
        // tslint:disable:no-forward-ref
        { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => JobPreparationTaskPickerComponent), multi: true },
        { provide: NG_VALIDATORS, useExisting: forwardRef(() => JobPreparationTaskPickerComponent), multi: true },
github spinnaker / deck / app / scripts / modules / core / src / task / PlatformHealthOverrideMessage.tsx View on Github external
lastCapacity.succeeded +
        lastCapacity.failed;

      // Confirm that a). we're stuck on a clone or create task (not, e.g., an enable task)
      // and b). the step we're stuck on is within that clone or create task.
      const isRelevantTask: boolean = props.task.execution.stages.some((stage: IStage) => {
        return (
          (stage.type === 'cloneServerGroup' || stage.type === 'createServerGroup') &&
          stage.tasks.some((task: ITimedItem) => task.startTime === props.step.startTime)
        );
      });

      showMessage =
        isRelevantTask &&
        props.step.name === 'waitForUpInstances' &&
        props.step.runningTimeInMs > Duration.fromObject({ minutes: 5 }).as('milliseconds') &&
        lastCapacity.unknown > 0 &&
        lastCapacity.unknown === lastCapacityTotal &&
        !get(props.application, 'attributes.platformHealthOnly');
    }

    this.state = { showMessage };
  }
github Thorium-Sim / thorium / src / components / views / CoreExtras / timer.js View on Github external
sendToSensors = () => {
    const [hours, minutes, seconds] = this.state.timer.split(":");
    const dur = Duration.fromObject({
      hours: parseInt(hours),
      minutes: parseInt(minutes),
      seconds: parseInt(seconds),
    }).normalize();
    const data = `Estimated time to arrival calculated: Approximately ${
      dur.hours > 0 ? `${dur.hours} hour${dur.hours === 1 ? "" : "s"}, ` : ""
    }${
      dur.minutes > 0
        ? `${dur.minutes} minute${dur.minutes === 1 ? "" : "s"}, `
        : ""
    }${dur.seconds} second${dur.seconds === 1 ? "" : "s"} at current speed.`;
    publish("sensorData", data);
  };
  render() {
github Thorium-Sim / thorium / client / src / components / views / Tasks / tasks.js View on Github external
function getElapsed(time) {
  return Object.entries(
    Duration.fromObject({
      hours: 0,
      minutes: 0,
      seconds: 0,
      milliseconds: Math.round(time)
    })
      .normalize()
      .toObject()
  )
    .filter(t => t[0] !== "milliseconds")
    .map(t => t[1].toString().padStart(2, 0))
    .join(":");
}
github eropple / taskbotjs / service / src / Config / Config.ts View on Github external
/**
   * If true, invokes `JobBase.setDefaultClientPool` with the `ClientPool` yielded
   * by this configuration to the service. This allows your TaskBotJS code to use
   * static methods on your job classes to invoke the jobs rather than having to
   * acquire a client themselves (which is faster if you have a batch to do, but is
   * also more boilerplate).
   *
   * @see JobBase
   */
  setDefaultClientPool: boolean = true;

  /**
   * Period of time to pause after each intake pass.
   */
  intakePause: TimeInterval = {
    interval: Duration.fromObject({ milliseconds: 5 }),
    splay: Duration.fromObject({})
  };

  /**
   * Period of time to pause after checking all workers for completion.
   */
  jobPause: TimeInterval = {
    interval: Duration.fromObject({milliseconds: 5 }),
    splay: Duration.fromObject({})
  };

  /**
   * Configuration for the retry poller.
   */
  retry: RetryConfig = {
    enabled: true,
github Thorium-Sim / thorium / client / src / components / views / SelfDestruct / core.js View on Github external
updateQuery: (previousResult, { subscriptionData }) => ({
        ...previousResult,
        simulators: subscriptionData.data.simulatorsUpdate
      })
    }),
    [simulator.id]
  );
  useSubscribeToMore(subscribeToMore, SELF_DESTRUCT_SUB, config);
  const { simulators } = data;
  if (loading || !simulators) return null;

  const { ship } = simulators[0];

  const { selfDestructTime, selfDestructCode, selfDestructAuto } = ship;

  const duration = Duration.fromObject({
    hours: 0,
    minutes: 0,
    seconds: 0,
    milliseconds: selfDestructTime
  }).normalize();
  return (
    
      <div>
        <label>
          Auto:{" "}
          <input checked="{selfDestructAuto}" type="checkbox">
        </label></div>