@abaplint/runtime 2.1.47 → 2.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/builtin/replace.js +1 -1
- package/build/src/compare/eq.js +2 -2
- package/build/src/operators/concat.js +2 -2
- package/build/src/statements/convert.js +7 -0
- package/build/src/template_formatting.d.ts +1 -1
- package/build/src/template_formatting.js +18 -9
- package/build/src/types/character.d.ts +1 -0
- package/build/src/types/character.js +3 -0
- package/build/src/types/string.js +1 -1
- package/package.json +1 -1
package/build/src/compare/eq.js
CHANGED
|
@@ -60,7 +60,7 @@ function eq(left, right) {
|
|
|
60
60
|
}
|
|
61
61
|
let l = undefined;
|
|
62
62
|
if (left instanceof types_1.Character) {
|
|
63
|
-
l = left.
|
|
63
|
+
l = left.getTrimEnd();
|
|
64
64
|
}
|
|
65
65
|
else if (typeof left === "object") {
|
|
66
66
|
l = left.get();
|
|
@@ -70,7 +70,7 @@ function eq(left, right) {
|
|
|
70
70
|
}
|
|
71
71
|
let r = undefined;
|
|
72
72
|
if (right instanceof types_1.Character) {
|
|
73
|
-
r = right.
|
|
73
|
+
r = right.getTrimEnd();
|
|
74
74
|
}
|
|
75
75
|
else if (typeof right === "object") {
|
|
76
76
|
r = right.get();
|
|
@@ -8,7 +8,7 @@ function concat(left, right) {
|
|
|
8
8
|
val += left;
|
|
9
9
|
}
|
|
10
10
|
else if (left instanceof types_1.Character) {
|
|
11
|
-
val += left.
|
|
11
|
+
val += left.getTrimEnd();
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
14
|
val += left.get();
|
|
@@ -17,7 +17,7 @@ function concat(left, right) {
|
|
|
17
17
|
val += right;
|
|
18
18
|
}
|
|
19
19
|
else if (right instanceof types_1.Character) {
|
|
20
|
-
val += right.
|
|
20
|
+
val += right.getTrimEnd();
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
23
|
val += right.get();
|
|
@@ -4,6 +4,7 @@ exports.convert = void 0;
|
|
|
4
4
|
const template_formatting_1 = require("../template_formatting");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
function convert(source, target) {
|
|
7
|
+
var _a, _b, _c;
|
|
7
8
|
let str = "";
|
|
8
9
|
if (source.date) {
|
|
9
10
|
if (typeof source.date === "string") {
|
|
@@ -31,6 +32,12 @@ function convert(source, target) {
|
|
|
31
32
|
}
|
|
32
33
|
str = (0, template_formatting_1.templateFormatting)(new types_1.Character({ length: 14 }).set(str), { timestamp: "iso" });
|
|
33
34
|
str += "Z";
|
|
35
|
+
if (str === "0000-00-00T00:00:00Z") {
|
|
36
|
+
(_a = target.stamp) === null || _a === void 0 ? void 0 : _a.clear();
|
|
37
|
+
(_b = target.date) === null || _b === void 0 ? void 0 : _b.clear();
|
|
38
|
+
(_c = target.time) === null || _c === void 0 ? void 0 : _c.clear();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
34
41
|
const t1 = new Date(Date.parse(str));
|
|
35
42
|
const out = t1.toISOString().slice(0, 19).replace(/-/g, "").replace(/:/g, "").replace("T", "");
|
|
36
43
|
if (target.stamp) {
|
|
@@ -10,5 +10,5 @@ declare type options = {
|
|
|
10
10
|
currency?: any;
|
|
11
11
|
align?: "left" | "right";
|
|
12
12
|
};
|
|
13
|
-
export declare function templateFormatting(source: ICharacter | INumeric, options
|
|
13
|
+
export declare function templateFormatting(source: ICharacter | INumeric, options?: options): string;
|
|
14
14
|
export {};
|
|
@@ -3,20 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.templateFormatting = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
function templateFormatting(source, options) {
|
|
6
|
-
let text =
|
|
7
|
-
if (
|
|
6
|
+
let text = "";
|
|
7
|
+
if (source instanceof types_1.Character) {
|
|
8
|
+
text = source.getTrimEnd();
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
text = source.get() + "";
|
|
12
|
+
}
|
|
13
|
+
if ((options === null || options === void 0 ? void 0 : options.currency) !== undefined) {
|
|
8
14
|
throw "template formatting with currency not supported";
|
|
9
15
|
}
|
|
10
|
-
if (options.timestamp === "iso") {
|
|
16
|
+
if ((options === null || options === void 0 ? void 0 : options.timestamp) === "iso") {
|
|
11
17
|
text = text.substr(0, 4) + "-" + text.substr(4, 2) + "-" + text.substr(6, 2) + "T" + text.substr(8, 2) + ":" + text.substr(10, 2) + ":" + text.substr(12, 2);
|
|
18
|
+
if (text === "0--T::") {
|
|
19
|
+
text = "0000-00-00T00:00:00";
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
|
-
if (options.date === "iso") {
|
|
22
|
+
if ((options === null || options === void 0 ? void 0 : options.date) === "iso") {
|
|
14
23
|
text = text.substr(0, 4) + "-" + text.substr(4, 2) + "-" + text.substr(6, 2);
|
|
15
24
|
}
|
|
16
|
-
if (options.time === "iso") {
|
|
25
|
+
if ((options === null || options === void 0 ? void 0 : options.time) === "iso") {
|
|
17
26
|
text = text.substr(0, 2) + ":" + text.substr(2, 2) + ":" + text.substr(4, 2);
|
|
18
27
|
}
|
|
19
|
-
if (options.width && options.pad) {
|
|
28
|
+
if ((options === null || options === void 0 ? void 0 : options.width) && options.pad) {
|
|
20
29
|
if (options.align === "right") {
|
|
21
30
|
text = text.trimEnd().padStart(options.width, options.pad);
|
|
22
31
|
}
|
|
@@ -24,13 +33,13 @@ function templateFormatting(source, options) {
|
|
|
24
33
|
text = text.trimEnd().padEnd(options.width, options.pad);
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
|
-
else if (options.width) {
|
|
36
|
+
else if (options === null || options === void 0 ? void 0 : options.width) {
|
|
28
37
|
text = text.trimEnd().padEnd(options.width, " ");
|
|
29
38
|
}
|
|
30
|
-
else if (options.decimals && source instanceof types_1.Integer) {
|
|
39
|
+
else if ((options === null || options === void 0 ? void 0 : options.decimals) && source instanceof types_1.Integer) {
|
|
31
40
|
text = source.get() + "." + "".padEnd(options.decimals, "0");
|
|
32
41
|
}
|
|
33
|
-
else if (options.decimals && source instanceof types_1.Packed) {
|
|
42
|
+
else if ((options === null || options === void 0 ? void 0 : options.decimals) && source instanceof types_1.Packed) {
|
|
34
43
|
text = source.get().toFixed(options.decimals);
|
|
35
44
|
}
|
|
36
45
|
return text;
|
|
@@ -40,6 +40,9 @@ class Character {
|
|
|
40
40
|
get() {
|
|
41
41
|
return this.value;
|
|
42
42
|
}
|
|
43
|
+
getTrimEnd() {
|
|
44
|
+
return this.value.replace(/ *$/, "");
|
|
45
|
+
}
|
|
43
46
|
getOffset(input) {
|
|
44
47
|
if (input === null || input === void 0 ? void 0 : input.offset) {
|
|
45
48
|
input.offset = (0, _parse_1.parse)(input.offset);
|
|
@@ -21,7 +21,7 @@ class String {
|
|
|
21
21
|
}
|
|
22
22
|
else if (value instanceof character_1.Character) {
|
|
23
23
|
// replace trailing blanks if the source is a Character string
|
|
24
|
-
this.value = value.
|
|
24
|
+
this.value = value.getTrimEnd();
|
|
25
25
|
}
|
|
26
26
|
else if (value instanceof integer_1.Integer) {
|
|
27
27
|
const lv_sign = (parseInt(value.get(), 10) >= 0) ? " " : "-";
|