Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(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",
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);
}
}
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);
}
}
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);
}
}
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));
}
}));
}
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"),
};
}
}
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();
}
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);
}
}