How to use the luxon.Duration.fromISO 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.2.x / flow_v0.104.x- / test_luxon.js View on Github external
(date.toSQLTime({ includeZone: true, includeOffset: true }): string);
// $ExpectError
(date.toSQLTime({ blah: true }): string);

(date.toString(): string);

(date.toUTC(): DateTime);
(date.toUTC(32): DateTime);
(date.toUTC(32, { keepCalendarTime: true }): DateTime);

(date.until(DateTime.utc()): Duration);

(date.valueOf(): number);

(Duration.fromISO("lkasdfa"): Duration);
(Duration.fromISO("lkasdfa", {
  locale: "de-DE",
  numberingSystem: "gujr",
  conversionAccuracy: "casual"
}): Duration);
// $ExpectError
(Duration.fromISO(): Duration);
// $ExpectError
(Duration.fromISO("lkasdfa", { foo: "bar" }): Duration);

(Duration.fromObject({ year: 1 }): Duration);
(Duration.fromObject({ years: 1 }): Duration);
(Duration.fromObject({ year: 1, months: 1 }): Duration);
(Duration.fromObject({
  year: 1,
  months: 1,
  locale: "de-DE",
github Azure / BatchExplorer / src / @batch-flask / ui / duration-picker / duration-picker.component.ts View on Github external
private _getCustomDuration(time: string) {
        const duration = Duration.fromISO(time);
        if (time === "P0D") {
            return duration;
        }
        if (!duration.isValid) {
            this.invalidCustomDuration = true;
            return null;
        } else {
            return Duration.fromISO(time);
        }
    }
github Azure / BatchExplorer / src / @batch-flask / core / record / record.ts View on Github external
private _createType(type: any, value: any) {
        const isPrimitive = primitives.has(type.name);
        if (isPrimitive) {
            return value;
        }
        if (type === Duration) {
            if (value instanceof Duration) {
                return value;
            } else if (typeof value === "string") {
                return Duration.fromISO(value);
            } else {
                return Duration.fromObject(value);
            }
        }
        return new type(value);
    }
}
github Azure / BatchExplorer / src / @batch-flask / ui / duration-picker / duration-picker.component.ts View on Github external
private _getCustomDuration(time: string) {
        const duration = Duration.fromISO(time);
        if (time === "P0D") {
            return duration;
        }
        if (!duration.isValid) {
            this.invalidCustomDuration = true;
            return null;
        } else {
            return Duration.fromISO(time);
        }
    }
github Azure / BatchExplorer / src / app / components / pool / action / scale / pool-scale-picker / pool-scale-picker.component.ts View on Github external
constructor(formBuilder: FormBuilder) {
        this.form = formBuilder.group({
            enableAutoScale: this._enableAutoScaleControl,
            autoScaleFormula: this._autoScaleFormulaControl,
            targetDedicatedNodes: this._targetDedicatedNodes,
            targetLowPriorityNodes: this._targetLowPriorityNodes,
            autoScaleEvaluationInterval: [Duration.fromISO("PT15M")],
            resizeTimeout: [Duration.fromISO("PT15M")],
        });

        this._subs.push(this._enableAutoScaleControl.valueChanges.subscribe((enableAutoScale) => {
            this._updateValidators(enableAutoScale);
        }));

        this._updateValidators(this._enableAutoScaleControl.value);

        this._subs.push(this.form.valueChanges.pipe(distinctUntilChanged()).subscribe((value) => {
            if (this._propagateChange) {
                this._propagateChange(cleanSelection(value));
            }
        }));
    }
github Azure / BatchExplorer / src / app / components / pool / action / scale / pool-scale-picker / pool-scale-picker.component.ts View on Github external
function cleanSelection(value: PoolScaleSelection): PoolScaleSelection {
    if (value.enableAutoScale) {
        return {
            enableAutoScale: true,
            autoScaleFormula: value.autoScaleFormula,
            autoScaleEvaluationInterval: value.autoScaleEvaluationInterval || Duration.fromISO("PT15M"),
        };
    } else {
        return {
            enableAutoScale: false,
            targetDedicatedNodes: value.targetDedicatedNodes,
            targetLowPriorityNodes: value.targetLowPriorityNodes,
            resizeTimeout: value.resizeTimeout || Duration.fromISO("PT15M"),
        };
    }
}
github Azure / BatchExplorer / src / @batch-flask / ui / duration-picker / duration-picker.component.ts View on Github external
public writeValue(value: Duration | string): void {
        if (value === null || value === undefined) {
            this.value = null;
        } else if (value instanceof Duration) {
            this.value = value;
        } else {
            this.value = Duration.fromISO(value);
        }
        this._setTimeAndUnitFromDuration(this.value);
        this.changeDetector.markForCheck();
    }
github Azure / BatchExplorer / src / @batch-flask / ui / duration-picker / duration-picker.component.ts View on Github external
private _getCustomDuration(time: string) {
        const duration = Duration.fromISO(time);
        if (time === "P0D") {
            return duration;
        }
        if (!duration.isValid) {
            this.invalidCustomDuration = true;
            return null;
        } else {
            return Duration.fromISO(time);
        }
    }