MCPcopy Create free account
hub / github.com/UI5/webcomponents / _modifyValueBy

Method _modifyValueBy

packages/main/src/TimePicker.ts:939–955  ·  view source on GitHub ↗
(amount: number, unit: string)

Source from the content-addressed store, hash-verified

937 }
938
939 _modifyValueBy(amount: number, unit: string) {
940 const date = this.getValueFormat().parse(this._effectiveValue) as Date;
941 if (!date) {
942 return;
943 }
944 if (unit === "hour") {
945 date.setHours(date.getHours() + amount);
946 } else if (unit === "minute") {
947 date.setMinutes(date.getMinutes() + amount);
948 } else if (unit === "second") {
949 date.setSeconds(date.getSeconds() + amount);
950 }
951
952 const newValue = this.formatValue(date);
953
954 this._updateValueAndFireEvents(newValue, true, ["change", "value-changed"]);
955 }
956
957 /**
958 * The listener for this event can't be passive as it calls preventDefault()

Callers 1

_onkeydownMethod · 0.95

Calls 4

getValueFormatMethod · 0.95
formatValueMethod · 0.95
parseMethod · 0.45

Tested by

no test coverage detected