@abaplint/runtime 2.7.110 → 2.7.112

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.
@@ -19,40 +19,24 @@ function templateFormatting(source, options) {
19
19
  else if (source instanceof types_1.Character) {
20
20
  text = source.getTrimEnd();
21
21
  }
22
- else {
23
- text = source.get() + "";
24
- }
25
- if ((options === null || options === void 0 ? void 0 : options.currency) !== undefined) {
26
- throw "template formatting with currency not supported";
27
- }
28
- if ((options === null || options === void 0 ? void 0 : options.date) === "iso") {
29
- text = text.substr(0, 4) + "-" + text.substr(4, 2) + "-" + text.substr(6, 2);
30
- }
31
- if ((options === null || options === void 0 ? void 0 : options.time) === "iso") {
32
- text = text.substr(0, 2) + ":" + text.substr(2, 2) + ":" + text.substr(4, 2);
33
- }
34
- if ((options === null || options === void 0 ? void 0 : options.timestamp) === "iso") {
35
- // make sure to get decimals from packed number,
36
- text = templateFormatting(source).replace(".", ",");
37
- 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) + text.substr(14);
38
- if (text === "0--T::") {
39
- text = "0000-00-00T00:00:00";
22
+ else if (source instanceof types_1.DecFloat34) {
23
+ const raw = source.getRaw();
24
+ if (Number.isInteger(raw)) {
25
+ text = raw.toFixed(0);
26
+ }
27
+ else {
28
+ text = raw + "";
40
29
  }
41
30
  }
42
- else if ((options === null || options === void 0 ? void 0 : options.width) && options.pad) {
43
- if (options.align === "right") {
44
- text = text.trimEnd().padStart(options.width, options.pad);
31
+ else if (source instanceof types_1.Float) {
32
+ const raw = source.getRaw();
33
+ if (Number.isInteger(raw)) {
34
+ text = raw.toFixed(0);
45
35
  }
46
36
  else {
47
- text = text.trimEnd().padEnd(options.width, options.pad);
37
+ text = raw.toFixed(16);
48
38
  }
49
39
  }
50
- else if (options === null || options === void 0 ? void 0 : options.width) {
51
- text = text.trimEnd().padEnd(options.width, " ");
52
- }
53
- else if ((options === null || options === void 0 ? void 0 : options.decimals) && source instanceof types_1.Integer) {
54
- text = source.get().toFixed(options.decimals);
55
- }
56
40
  else if (source instanceof types_1.Packed) {
57
41
  if (options === null || options === void 0 ? void 0 : options.decimals) {
58
42
  text = source.get().toFixed(options.decimals);
@@ -61,25 +45,43 @@ function templateFormatting(source, options) {
61
45
  text = source.get().toFixed(source.getDecimals());
62
46
  }
63
47
  }
64
- else if ((options === null || options === void 0 ? void 0 : options.decimals) && source instanceof types_1.Float) {
65
- text = source.getRaw().toFixed(options.decimals);
48
+ else {
49
+ text = source.get() + "";
66
50
  }
67
- else if (source instanceof types_1.DecFloat34) {
68
- const raw = source.getRaw();
69
- if (Number.isInteger(raw)) {
70
- text = raw.toFixed(0);
51
+ if (options) {
52
+ if (options.currency !== undefined) {
53
+ throw "template formatting with currency not supported";
71
54
  }
72
- else {
73
- text = raw + "";
55
+ if (options.date === "iso") {
56
+ text = text.substr(0, 4) + "-" + text.substr(4, 2) + "-" + text.substr(6, 2);
74
57
  }
75
- }
76
- else if (source instanceof types_1.Float) {
77
- const raw = source.getRaw();
78
- if (Number.isInteger(raw)) {
79
- text = raw.toFixed(0);
58
+ if (options.time === "iso") {
59
+ text = text.substr(0, 2) + ":" + text.substr(2, 2) + ":" + text.substr(4, 2);
80
60
  }
81
- else {
82
- text = raw.toFixed(16);
61
+ if (options.timestamp === "iso") {
62
+ // make sure to get decimals from packed number,
63
+ text = templateFormatting(source).replace(".", ",");
64
+ 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) + text.substr(14);
65
+ if (text === "0--T::") {
66
+ text = "0000-00-00T00:00:00";
67
+ }
68
+ }
69
+ else if (options.width && options.pad) {
70
+ if (options.align === "right") {
71
+ text = text.trimEnd().padStart(options.width, options.pad);
72
+ }
73
+ else {
74
+ text = text.trimEnd().padEnd(options.width, options.pad);
75
+ }
76
+ }
77
+ else if (options.width) {
78
+ text = text.trimEnd().padEnd(options.width, " ");
79
+ }
80
+ else if (options.decimals && source instanceof types_1.Integer) {
81
+ text = source.get().toFixed(options.decimals);
82
+ }
83
+ else if (options.decimals && source instanceof types_1.Float) {
84
+ text = source.getRaw().toFixed(options.decimals);
83
85
  }
84
86
  }
85
87
  return text;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.7.110",
3
+ "version": "2.7.112",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",