@abaplint/runtime 2.13.64 → 2.13.65

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.
@@ -76,9 +76,38 @@ function templateFormatting(source, options) {
76
76
  if (options.date === "iso") {
77
77
  text = text.substr(0, 4) + "-" + text.substr(4, 2) + "-" + text.substr(6, 2);
78
78
  }
79
+ else if (options.date === "user" || options.date === "environment") {
80
+ const yyyy = text.substr(0, 4);
81
+ const mm = text.substr(4, 2);
82
+ const dd = text.substr(6, 2);
83
+ const date = new Date(`${yyyy}-${mm}-${dd}T00:00:00`);
84
+ if (isNaN(date.getTime())) {
85
+ text = "00000000"; // Default SAP behaviour
86
+ }
87
+ else {
88
+ text = new Intl.DateTimeFormat("default", { day: "2-digit", month: "2-digit", year: "numeric" }).format(date);
89
+ }
90
+ }
79
91
  if (options.time === "iso") {
80
92
  text = text.substr(0, 2) + ":" + text.substr(2, 2) + ":" + text.substr(4, 2);
81
93
  }
94
+ else if (options.time === "user" || options.time === "environment") {
95
+ const hh = text.substr(0, 2);
96
+ const mm = text.substr(2, 2);
97
+ const ss = text.substr(4, 2) || "00";
98
+ const timeDate = new Date(`1970-01-01T${hh}:${mm}:${ss}`);
99
+ if (isNaN(timeDate.getTime())) {
100
+ text = ""; // Default SAP behaviour
101
+ }
102
+ else {
103
+ // Leaving out hour12 makes it use the exact environment defaults!
104
+ text = new Intl.DateTimeFormat("default", {
105
+ hour: "2-digit",
106
+ minute: "2-digit",
107
+ second: "2-digit",
108
+ }).format(timeDate);
109
+ }
110
+ }
82
111
  if (options.timestamp === "iso") {
83
112
  // make sure to get decimals from packed number,
84
113
  text = templateFormatting(source).replace(".", ",");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.13.64",
3
+ "version": "2.13.65",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",