@ui5/webcomponents-localization 0.0.0-3790e6927 → 0.0.0-3e3654870
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/CHANGELOG.md +194 -0
- package/README.md +1 -0
- package/dist/dates/modifyDateBy.d.ts +2 -1
- package/dist/dates/modifyDateBy.js +34 -19
- package/dist/dates/modifyDateBy.js.map +1 -1
- package/dist/sap/base/i18n/LanguageTag.js +35 -0
- package/dist/sap/base/i18n/Localization.d.ts +4 -0
- package/dist/sap/base/i18n/Localization.js +12 -0
- package/dist/sap/base/i18n/Localization.js.map +1 -0
- package/dist/sap/base/i18n/date/CalendarType.js +8 -0
- package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +30 -0
- package/dist/sap/base/i18n/date/TimezoneUtils.js +89 -0
- package/dist/sap/ui/base/Metadata.js +20 -9
- package/dist/sap/ui/core/CalendarType.js +2 -8
- package/dist/sap/ui/core/Configuration.d.ts +1 -0
- package/dist/sap/ui/core/Configuration.js +2 -0
- package/dist/sap/ui/core/Configuration.js.map +1 -1
- package/dist/sap/ui/core/Core.d.ts +1 -0
- package/dist/sap/ui/core/Locale.js +28 -125
- package/dist/sap/ui/core/LocaleData.js +36 -18
- package/dist/sap/ui/core/date/CalendarUtils.js +7 -18
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +2 -7
- package/dist/sap/ui/core/date/UniversalDate.js +5 -16
- package/dist/sap/ui/core/format/DateFormat.js +79 -37
- package/dist/sap/ui/core/format/TimezoneUtil.js +2 -89
- package/package.json +5 -5
- package/used-modules.txt +4 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,200 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.19.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.19.0-rc.0...v1.19.0-rc.1) (2023-10-19)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [1.19.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.18.1-rc.0...v1.19.0-rc.0) (2023-10-12)
|
15
|
+
|
16
|
+
|
17
|
+
### Bug Fixes
|
18
|
+
|
19
|
+
* **localization:** missing calendarWeekNumbering ([#7684](https://github.com/SAP/ui5-webcomponents/issues/7684)) ([01a9349](https://github.com/SAP/ui5-webcomponents/commit/01a9349c7ab5e3c046fa10034dc9aa99b840f3d0))
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
## [1.18.1-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.18.0...v1.18.1-rc.0) (2023-10-05)
|
26
|
+
|
27
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
# [1.18.0](https://github.com/SAP/ui5-webcomponents/compare/v1.18.0-rc.2...v1.18.0) (2023-10-02)
|
34
|
+
|
35
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
# [1.18.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.18.0-rc.1...v1.18.0-rc.2) (2023-09-28)
|
42
|
+
|
43
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
# [1.18.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.18.0-rc.0...v1.18.0-rc.1) (2023-09-21)
|
50
|
+
|
51
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
# [1.18.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.17.0...v1.18.0-rc.0) (2023-09-07)
|
58
|
+
|
59
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
# [1.17.0](https://github.com/SAP/ui5-webcomponents/compare/v1.17.0-rc.2...v1.17.0) (2023-09-01)
|
66
|
+
|
67
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
# [1.17.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.17.0-rc.1...v1.17.0-rc.2) (2023-08-24)
|
74
|
+
|
75
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
# [1.17.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.17.0-rc.0...v1.17.0-rc.1) (2023-08-17)
|
82
|
+
|
83
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
# [1.17.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0...v1.17.0-rc.0) (2023-08-10)
|
90
|
+
|
91
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
# [1.16.0](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.4...v1.16.0) (2023-08-03)
|
98
|
+
|
99
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
# [1.16.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.3...v1.16.0-rc.4) (2023-08-03)
|
106
|
+
|
107
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
# [1.16.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.2...v1.16.0-rc.3) (2023-07-27)
|
114
|
+
|
115
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
# [1.16.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.1...v1.16.0-rc.2) (2023-07-20)
|
122
|
+
|
123
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
# [1.16.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.0...v1.16.0-rc.1) (2023-07-13)
|
130
|
+
|
131
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
# [1.16.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.15.1...v1.16.0-rc.0) (2023-07-06)
|
138
|
+
|
139
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
# [1.15.0](https://github.com/SAP/ui5-webcomponents/compare/v1.15.0-rc.2...v1.15.0) (2023-06-30)
|
146
|
+
|
147
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
# [1.15.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.15.0-rc.1...v1.15.0-rc.2) (2023-06-22)
|
154
|
+
|
155
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
# [1.15.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.15.0-rc.0...v1.15.0-rc.1) (2023-06-15)
|
162
|
+
|
163
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
# [1.15.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0...v1.15.0-rc.0) (2023-06-08)
|
174
|
+
|
175
|
+
|
176
|
+
### Bug Fixes
|
177
|
+
|
178
|
+
* **ui5-calendar:** prevent focus loss during arrow navigation with mouse/touch ([#6957](https://github.com/SAP/ui5-webcomponents/issues/6957)) ([216f6a7](https://github.com/SAP/ui5-webcomponents/commit/216f6a7a476d18a0f6fdf7ff189f953085e30b47))
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
# [1.14.0](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0-rc.2...v1.14.0) (2023-06-01)
|
185
|
+
|
186
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
# [1.14.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0-rc.1...v1.14.0-rc.2) (2023-06-01)
|
193
|
+
|
194
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
6
200
|
# [1.14.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0-rc.0...v1.14.0-rc.1) (2023-05-25)
|
7
201
|
|
8
202
|
**Note:** Version bump only for package @ui5/webcomponents-localization
|
package/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|

|
2
2
|
|
3
|
+
|
3
4
|
# UI5 Web Components - Localization
|
4
5
|
|
5
6
|
[](https://www.npmjs.com/package/@ui5/webcomponents)
|
@@ -6,8 +6,9 @@ import CalendarDate from "./CalendarDate.js";
|
|
6
6
|
* @param date CalendarDate instance
|
7
7
|
* @param amount how many days/months/years to add (can be a negative number)
|
8
8
|
* @param unit what to modify: "day", "month" or "year"
|
9
|
+
* @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)
|
9
10
|
* @param minDate minimum date to enforce
|
10
11
|
* @param maxDate maximum date to enforce
|
11
12
|
*/
|
12
|
-
declare const modifyDateBy: (date: CalendarDate, amount: number, unit: string, minDate?: CalendarDate, maxDate?: CalendarDate) => CalendarDate;
|
13
|
+
declare const modifyDateBy: (date: CalendarDate, amount: number, unit: string, preserveDate?: boolean, minDate?: CalendarDate, maxDate?: CalendarDate) => CalendarDate;
|
13
14
|
export default modifyDateBy;
|
@@ -6,32 +6,47 @@ import CalendarDate from "./CalendarDate.js";
|
|
6
6
|
* @param date CalendarDate instance
|
7
7
|
* @param amount how many days/months/years to add (can be a negative number)
|
8
8
|
* @param unit what to modify: "day", "month" or "year"
|
9
|
+
* @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)
|
9
10
|
* @param minDate minimum date to enforce
|
10
11
|
* @param maxDate maximum date to enforce
|
11
12
|
*/
|
12
|
-
const modifyDateBy = (date, amount, unit, minDate, maxDate) => {
|
13
|
+
const modifyDateBy = (date, amount, unit, preserveDate = true, minDate, maxDate) => {
|
13
14
|
const newDate = new CalendarDate(date);
|
14
|
-
|
15
|
-
|
15
|
+
switch (unit) {
|
16
|
+
case "day":
|
17
|
+
newDate.setDate(date.getDate() + amount);
|
18
|
+
break;
|
19
|
+
case "month":
|
20
|
+
if (preserveDate) {
|
21
|
+
newDate.setMonth(date.getMonth() + amount);
|
22
|
+
const stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month
|
23
|
+
const monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month
|
24
|
+
if (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios
|
25
|
+
newDate.setDate(0);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
if (amount === 1) {
|
30
|
+
newDate.setMonth(newDate.getMonth() + 1, 1);
|
31
|
+
}
|
32
|
+
if (amount === -1) {
|
33
|
+
newDate.setDate(0);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
break;
|
37
|
+
case "year":
|
38
|
+
newDate.setYear(date.getYear() + amount);
|
39
|
+
if (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year
|
40
|
+
newDate.setDate(0); // Select the last day of the month
|
41
|
+
}
|
42
|
+
break;
|
43
|
+
default:
|
44
|
+
break;
|
16
45
|
}
|
17
|
-
|
18
|
-
newDate.setMonth(date.getMonth() + amount);
|
19
|
-
const stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month
|
20
|
-
const monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month
|
21
|
-
if (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios
|
22
|
-
newDate.setDate(0);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
newDate.setYear(date.getYear() + amount);
|
27
|
-
if (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year
|
28
|
-
newDate.setDate(0); // Select the last day of the month
|
29
|
-
}
|
30
|
-
}
|
31
|
-
if (minDate && newDate.valueOf() < minDate.valueOf()) {
|
46
|
+
if (minDate && newDate.isBefore(minDate)) {
|
32
47
|
return new CalendarDate(minDate);
|
33
48
|
}
|
34
|
-
if (maxDate && newDate.
|
49
|
+
if (maxDate && newDate.isAfter(maxDate)) {
|
35
50
|
return new CalendarDate(maxDate);
|
36
51
|
}
|
37
52
|
return newDate;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"modifyDateBy.js","sourceRoot":"","sources":["../../src/dates/modifyDateBy.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C
|
1
|
+
{"version":3,"file":"modifyDateBy.js","sourceRoot":"","sources":["../../src/dates/modifyDateBy.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,MAAc,EAAE,IAAY,EAAE,YAAY,GAAG,IAAI,EAAE,OAAsB,EAAE,OAAsB,EAAE,EAAE;IAC9I,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAEvC,QAAQ,IAAI,EAAE;QACd,KAAK,KAAK;YACT,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;YACzC,MAAM;QACP,KAAK,OAAO;YACX,IAAI,YAAY,EAAE;gBACjB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC;gBAC3C,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,yCAAyC;gBACzH,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,sCAAsC;gBACrH,IAAI,cAAc,IAAI,YAAY,EAAE,EAAE,+DAA+D;oBACpG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACnB;aACD;iBAAM;gBACN,IAAI,MAAM,KAAK,CAAC,EAAE;oBACjB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;iBAC5C;gBACD,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE;oBAClB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACnB;aACD;YACD,MAAM;QACP,KAAK,MAAM;YACV,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;YACzC,IAAI,OAAO,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,kCAAkC;gBAC/E,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC;aACvD;YACD,MAAM;QACP;YACC,MAAM;KACN;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACzC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;KACjC;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACxC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;KACjC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import CalendarDate from \"./CalendarDate.js\";\n\n/**\n * Adds or subtracts a given amount of days/months/years from a date.\n * If minDate or maxDate are given, the result will be enforced within these limits\n *\n * @param date CalendarDate instance\n * @param amount how many days/months/years to add (can be a negative number)\n * @param unit what to modify: \"day\", \"month\" or \"year\"\n * @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)\n * @param minDate minimum date to enforce\n * @param maxDate maximum date to enforce\n */\nconst modifyDateBy = (date: CalendarDate, amount: number, unit: string, preserveDate = true, minDate?: CalendarDate, maxDate?: CalendarDate) => {\n\tconst newDate = new CalendarDate(date);\n\n\tswitch (unit) {\n\tcase \"day\":\n\t\tnewDate.setDate(date.getDate() + amount);\n\t\tbreak;\n\tcase \"month\":\n\t\tif (preserveDate) {\n\t\t\tnewDate.setMonth(date.getMonth() + amount);\n\t\t\tconst stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month\n\t\t\tconst monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month\n\t\t\tif (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios\n\t\t\t\tnewDate.setDate(0);\n\t\t\t}\n\t\t} else {\n\t\t\tif (amount === 1) {\n\t\t\t\tnewDate.setMonth(newDate.getMonth() + 1, 1);\n\t\t\t}\n\t\t\tif (amount === -1) {\n\t\t\t\tnewDate.setDate(0);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase \"year\":\n\t\tnewDate.setYear(date.getYear() + amount);\n\t\tif (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year\n\t\t\tnewDate.setDate(0); // Select the last day of the month\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\tif (minDate && newDate.isBefore(minDate)) {\n\t\treturn new CalendarDate(minDate);\n\t}\n\n\tif (maxDate && newDate.isAfter(maxDate)) {\n\t\treturn new CalendarDate(maxDate);\n\t}\n\n\treturn newDate;\n};\n\nexport default modifyDateBy;\n"]}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
var rLanguageTag = /^((?:[A-Z]{2,3}(?:-[A-Z]{3}){0,3})|[A-Z]{4}|[A-Z]{5,8})(?:-([A-Z]{4}))?(?:-([A-Z]{2}|[0-9]{3}))?((?:-[0-9A-Z]{5,8}|-[0-9][0-9A-Z]{3})*)((?:-[0-9A-WYZ](?:-[0-9A-Z]{2,8})+)*)(?:-(X(?:-[0-9A-Z]{1,8})+))?$/i;
|
2
|
+
var LanguageTag = function (sLanguageTag) {
|
3
|
+
var aResult = rLanguageTag.exec(sLanguageTag.replace(/_/g, "-"));
|
4
|
+
if (aResult === null) {
|
5
|
+
throw new TypeError("The given language tag'" + sLanguageTag + "' does not adhere to BCP-47.");
|
6
|
+
}
|
7
|
+
this.language = aResult[1] || null;
|
8
|
+
this.script = aResult[2] || null;
|
9
|
+
this.region = aResult[3] || null;
|
10
|
+
this.variant = aResult[4] && aResult[4].slice(1) || null;
|
11
|
+
this.variantSubtags = this.variant ? this.variant.split("-") : [];
|
12
|
+
this.extension = aResult[5] && aResult[5].slice(1) || null;
|
13
|
+
this.extensionSubtags = this.variant ? this.variant.split("-") : [];
|
14
|
+
this.privateUse = aResult[6] || null;
|
15
|
+
this.privateUseSubtags = this.privateUse ? this.privateUse.slice(2).split("-") : [];
|
16
|
+
if (this.language) {
|
17
|
+
this.language = this.language.toLowerCase();
|
18
|
+
}
|
19
|
+
if (this.script) {
|
20
|
+
this.script = this.script.toLowerCase().replace(/^[a-z]/, function ($) {
|
21
|
+
return $.toUpperCase();
|
22
|
+
});
|
23
|
+
}
|
24
|
+
if (this.region) {
|
25
|
+
this.region = this.region.toUpperCase();
|
26
|
+
}
|
27
|
+
Object.freeze(this);
|
28
|
+
};
|
29
|
+
LanguageTag.prototype.toString = function () {
|
30
|
+
return join(this.language, this.script, this.region, this.variant, this.extension, this.privateUse);
|
31
|
+
};
|
32
|
+
function join() {
|
33
|
+
return Array.prototype.filter.call(arguments, Boolean).join("-");
|
34
|
+
}
|
35
|
+
export default LanguageTag;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
const M_ISO639_OLD_TO_NEW = {
|
2
|
+
"iw": "he",
|
3
|
+
"ji": "yi",
|
4
|
+
};
|
5
|
+
const getModernLanguage = (sLanguage) => {
|
6
|
+
return M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
|
7
|
+
};
|
8
|
+
const Localization = {
|
9
|
+
getModernLanguage,
|
10
|
+
};
|
11
|
+
export default Localization;
|
12
|
+
//# sourceMappingURL=Localization.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Localization.js","sourceRoot":"","sources":["../../../../src/sap/base/i18n/Localization.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG;IAC3B,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;CACV,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC/C,OAAO,mBAAmB,CAAC,SAA6C,CAAC,IAAI,SAAS,CAAC;AACxF,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG;IACpB,iBAAiB;CACjB,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["const M_ISO639_OLD_TO_NEW = {\n\t\"iw\": \"he\",\n\t\"ji\": \"yi\",\n};\n\nconst getModernLanguage = (sLanguage: string) => {\n\treturn M_ISO639_OLD_TO_NEW[sLanguage as keyof typeof M_ISO639_OLD_TO_NEW] || sLanguage;\n};\n\nconst Localization = {\n\tgetModernLanguage,\n};\n\nexport default Localization;\n"]}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var CalendarWeekNumbering = {
|
2
|
+
Default: "Default",
|
3
|
+
ISO_8601: "ISO_8601",
|
4
|
+
MiddleEastern: "MiddleEastern",
|
5
|
+
WesternTraditional: "WesternTraditional"
|
6
|
+
};
|
7
|
+
Object.defineProperty(CalendarWeekNumbering, "getWeekConfigurationValues", {
|
8
|
+
value: function (sCalendarWeekNumbering) {
|
9
|
+
switch (sCalendarWeekNumbering) {
|
10
|
+
case CalendarWeekNumbering.ISO_8601:
|
11
|
+
return {
|
12
|
+
firstDayOfWeek: 1,
|
13
|
+
minimalDaysInFirstWeek: 4
|
14
|
+
};
|
15
|
+
case CalendarWeekNumbering.MiddleEastern:
|
16
|
+
return {
|
17
|
+
firstDayOfWeek: 6,
|
18
|
+
minimalDaysInFirstWeek: 1
|
19
|
+
};
|
20
|
+
case CalendarWeekNumbering.WesternTraditional:
|
21
|
+
return {
|
22
|
+
firstDayOfWeek: 0,
|
23
|
+
minimalDaysInFirstWeek: 1
|
24
|
+
};
|
25
|
+
default:
|
26
|
+
return undefined;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
});
|
30
|
+
export default CalendarWeekNumbering;
|
@@ -0,0 +1,89 @@
|
|
1
|
+
var TimezoneUtils = {};
|
2
|
+
var sLocalTimezone = "";
|
3
|
+
var aSupportedTimezoneIDs;
|
4
|
+
var oIntlDateTimeFormatCache = {
|
5
|
+
_oCache: new Map(),
|
6
|
+
_iCacheLimit: 10,
|
7
|
+
get: function (sTimezone) {
|
8
|
+
var cacheEntry = this._oCache.get(sTimezone);
|
9
|
+
if (cacheEntry) {
|
10
|
+
return cacheEntry;
|
11
|
+
}
|
12
|
+
var oOptions = {
|
13
|
+
hourCycle: "h23",
|
14
|
+
hour: "2-digit",
|
15
|
+
minute: "2-digit",
|
16
|
+
second: "2-digit",
|
17
|
+
fractionalSecondDigits: 3,
|
18
|
+
day: "2-digit",
|
19
|
+
month: "2-digit",
|
20
|
+
year: "numeric",
|
21
|
+
timeZone: sTimezone,
|
22
|
+
timeZoneName: "short",
|
23
|
+
era: "narrow",
|
24
|
+
weekday: "short"
|
25
|
+
};
|
26
|
+
var oInstance = new Intl.DateTimeFormat("en-US", oOptions);
|
27
|
+
if (this._oCache.size === this._iCacheLimit) {
|
28
|
+
this._oCache = new Map();
|
29
|
+
}
|
30
|
+
this._oCache.set(sTimezone, oInstance);
|
31
|
+
return oInstance;
|
32
|
+
}
|
33
|
+
};
|
34
|
+
TimezoneUtils.isValidTimezone = function (sTimezone) {
|
35
|
+
if (!sTimezone) {
|
36
|
+
return false;
|
37
|
+
}
|
38
|
+
if (Intl.supportedValuesOf) {
|
39
|
+
try {
|
40
|
+
aSupportedTimezoneIDs = aSupportedTimezoneIDs || Intl.supportedValuesOf("timeZone");
|
41
|
+
if (aSupportedTimezoneIDs.includes(sTimezone)) {
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
} catch (oError) {
|
45
|
+
aSupportedTimezoneIDs = [];
|
46
|
+
}
|
47
|
+
}
|
48
|
+
try {
|
49
|
+
oIntlDateTimeFormatCache.get(sTimezone);
|
50
|
+
return true;
|
51
|
+
} catch (oError) {
|
52
|
+
return false;
|
53
|
+
}
|
54
|
+
};
|
55
|
+
TimezoneUtils.convertToTimezone = function (oDate, sTargetTimezone) {
|
56
|
+
var oFormatParts = this._getParts(oDate, sTargetTimezone);
|
57
|
+
return TimezoneUtils._getDateFromParts(oFormatParts);
|
58
|
+
};
|
59
|
+
TimezoneUtils._getParts = function (oDate, sTargetTimezone) {
|
60
|
+
var sKey, oPart, oDateParts = Object.create(null), oIntlDate = oIntlDateTimeFormatCache.get(sTargetTimezone), oParts = oIntlDate.formatToParts(new Date(oDate.getTime()));
|
61
|
+
for (sKey in oParts) {
|
62
|
+
oPart = oParts[sKey];
|
63
|
+
if (oPart.type !== "literal") {
|
64
|
+
oDateParts[oPart.type] = oPart.value;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
return oDateParts;
|
68
|
+
};
|
69
|
+
TimezoneUtils._getDateFromParts = function (oParts) {
|
70
|
+
var oDate = new Date(0), iUTCYear = parseInt(oParts.year);
|
71
|
+
if (oParts.era === "B") {
|
72
|
+
iUTCYear = iUTCYear * -1 + 1;
|
73
|
+
}
|
74
|
+
oDate.setUTCFullYear(iUTCYear, parseInt(oParts.month) - 1, parseInt(oParts.day));
|
75
|
+
oDate.setUTCHours(parseInt(oParts.hour), parseInt(oParts.minute), parseInt(oParts.second), parseInt(oParts.fractionalSecond || 0));
|
76
|
+
return oDate;
|
77
|
+
};
|
78
|
+
TimezoneUtils.calculateOffset = function (oDate, sTimezoneSource) {
|
79
|
+
var oFirstGuess = this.convertToTimezone(oDate, sTimezoneSource), iInitialOffset = oDate.getTime() - oFirstGuess.getTime(), oDateSource = new Date(oDate.getTime() + iInitialOffset), oDateTarget = this.convertToTimezone(oDateSource, sTimezoneSource);
|
80
|
+
return (oDateSource.getTime() - oDateTarget.getTime()) / 1000;
|
81
|
+
};
|
82
|
+
TimezoneUtils.getLocalTimezone = function () {
|
83
|
+
if (sLocalTimezone) {
|
84
|
+
return sLocalTimezone;
|
85
|
+
}
|
86
|
+
sLocalTimezone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
87
|
+
return sLocalTimezone;
|
88
|
+
};
|
89
|
+
export default TimezoneUtils;
|
@@ -2,6 +2,9 @@ import ObjectPath from '../../base/util/ObjectPath.js';
|
|
2
2
|
import assert from '../../base/assert.js';
|
3
3
|
import Log from '../../base/Log.js';
|
4
4
|
import uniqueSort from '../../base/util/array/uniqueSort.js';
|
5
|
+
function isFunction(obj) {
|
6
|
+
return typeof obj === 'function';
|
7
|
+
}
|
5
8
|
var Metadata = function (sClassName, oClassInfo) {
|
6
9
|
assert(typeof sClassName === 'string' && sClassName, 'Metadata: sClassName must be a non-empty string');
|
7
10
|
assert(typeof oClassInfo === 'object', 'Metadata: oClassInfo must be empty or an object');
|
@@ -13,7 +16,7 @@ var Metadata = function (sClassName, oClassInfo) {
|
|
13
16
|
oClassInfo.metadata.__version = 1;
|
14
17
|
}
|
15
18
|
oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2;
|
16
|
-
if (
|
19
|
+
if (!isFunction(oClassInfo.constructor)) {
|
17
20
|
throw Error('constructor for class ' + sClassName + ' must have been declared before creating metadata for it');
|
18
21
|
}
|
19
22
|
this._sClassName = sClassName;
|
@@ -27,9 +30,17 @@ Metadata.prototype.extend = function (oClassInfo) {
|
|
27
30
|
Metadata.prototype.applySettings = function (oClassInfo) {
|
28
31
|
var that = this, oStaticInfo = oClassInfo.metadata, oPrototype;
|
29
32
|
if (oStaticInfo.baseType) {
|
30
|
-
var oParentClass
|
31
|
-
if (
|
32
|
-
|
33
|
+
var oParentClass;
|
34
|
+
if (isFunction(oStaticInfo.baseType)) {
|
35
|
+
oParentClass = oStaticInfo.baseType;
|
36
|
+
if (!isFunction(oParentClass.getMetadata)) {
|
37
|
+
throw new TypeError('baseType must be a UI5 class with a static getMetadata function');
|
38
|
+
}
|
39
|
+
} else {
|
40
|
+
oParentClass = ObjectPath.get(oStaticInfo.baseType);
|
41
|
+
if (!isFunction(oParentClass)) {
|
42
|
+
Log.fatal('base class \'' + oStaticInfo.baseType + '\' does not exist');
|
43
|
+
}
|
33
44
|
}
|
34
45
|
if (oParentClass.getMetadata) {
|
35
46
|
this._oParent = oParentClass.getMetadata();
|
@@ -167,12 +178,12 @@ Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl
|
|
167
178
|
sClassName = fnBaseClass;
|
168
179
|
fnBaseClass = null;
|
169
180
|
}
|
170
|
-
assert(!fnBaseClass ||
|
181
|
+
assert(!fnBaseClass || isFunction(fnBaseClass));
|
171
182
|
assert(typeof sClassName === 'string' && !!sClassName);
|
172
183
|
assert(!oClassInfo || typeof oClassInfo === 'object');
|
173
|
-
assert(!FNMetaImpl ||
|
184
|
+
assert(!FNMetaImpl || isFunction(FNMetaImpl));
|
174
185
|
FNMetaImpl = FNMetaImpl || Metadata;
|
175
|
-
if (
|
186
|
+
if (isFunction(FNMetaImpl.preprocessClassInfo)) {
|
176
187
|
oClassInfo = FNMetaImpl.preprocessClassInfo(oClassInfo);
|
177
188
|
}
|
178
189
|
oClassInfo = oClassInfo || {};
|
@@ -181,7 +192,7 @@ Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl
|
|
181
192
|
oClassInfo.constructor = undefined;
|
182
193
|
}
|
183
194
|
var fnClass = oClassInfo.constructor;
|
184
|
-
assert(!fnClass ||
|
195
|
+
assert(!fnClass || isFunction(fnClass));
|
185
196
|
if (fnBaseClass) {
|
186
197
|
if (!fnClass) {
|
187
198
|
if (oClassInfo.metadata.deprecated) {
|
@@ -197,7 +208,7 @@ Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl
|
|
197
208
|
}
|
198
209
|
fnClass.prototype = Object.create(fnBaseClass.prototype);
|
199
210
|
fnClass.prototype.constructor = fnClass;
|
200
|
-
oClassInfo.metadata.baseType = fnBaseClass
|
211
|
+
oClassInfo.metadata.baseType = fnBaseClass;
|
201
212
|
} else {
|
202
213
|
fnClass = fnClass || function () {
|
203
214
|
};
|
@@ -1,8 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Islamic: "Islamic",
|
4
|
-
Japanese: "Japanese",
|
5
|
-
Persian: "Persian",
|
6
|
-
Buddhist: "Buddhist"
|
7
|
-
};
|
8
|
-
export default CalendarType;
|
1
|
+
import CalendarType from '../../base/i18n/date/CalendarType.js';
|
2
|
+
export default CalendarType;
|
@@ -13,5 +13,6 @@ declare const Configuration: {
|
|
13
13
|
getLegacyDateCalendarCustomizing: typeof import("@ui5/webcomponents-base/dist/features/LegacyDateFormats.js").default.getLegacyDateCalendarCustomizing;
|
14
14
|
};
|
15
15
|
getTimezone: () => string;
|
16
|
+
getCalendarWeekNumbering: () => string;
|
16
17
|
};
|
17
18
|
export default Configuration;
|
@@ -16,6 +16,8 @@ const Configuration = {
|
|
16
16
|
getOriginInfo: emptyFn,
|
17
17
|
getFormatSettings: () => FormatSettings,
|
18
18
|
getTimezone: () => getConfigTimezone() || TimezoneUtil.getLocalTimezone(),
|
19
|
+
// Calculate calendar week numbering by active format locale
|
20
|
+
getCalendarWeekNumbering: () => "Default",
|
19
21
|
};
|
20
22
|
export default Configuration;
|
21
23
|
//# sourceMappingURL=Configuration.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../../src/sap/ui/core/Configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AACtF,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,4BAA4B,MAAM,mEAAmE,CAAC;AAC7G,aAAa;AACb,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,MAAM,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEzB;;GAEG;AACH,MAAM,aAAa,GAAG;IACrB,WAAW;IACX,eAAe;IACf,qBAAqB,EAAE,GAAG,EAAE,CAAC,4BAA4B,CAAC,2IAA2I,CAAC;IACtM,aAAa,EAAE,OAAO;IACtB,iBAAiB,EAAE,GAAG,EAAE,CAAC,cAAc;IACvC,WAAW,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE,IAAI,YAAY,CAAC,gBAAgB,EAAY;
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../../src/sap/ui/core/Configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AACtF,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,4BAA4B,MAAM,mEAAmE,CAAC;AAC7G,aAAa;AACb,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,MAAM,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEzB;;GAEG;AACH,MAAM,aAAa,GAAG;IACrB,WAAW;IACX,eAAe;IACf,qBAAqB,EAAE,GAAG,EAAE,CAAC,4BAA4B,CAAC,2IAA2I,CAAC;IACtM,aAAa,EAAE,OAAO;IACtB,iBAAiB,EAAE,GAAG,EAAE,CAAC,cAAc;IACvC,WAAW,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE,IAAI,YAAY,CAAC,gBAAgB,EAAY;IACnF,4DAA4D;IAC5D,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;CACzC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { getLanguage } from \"@ui5/webcomponents-base/dist/config/Language.js\";\nimport { getCalendarType } from \"@ui5/webcomponents-base/dist/config/CalendarType.js\";\nimport { getTimezone as getConfigTimezone } from \"@ui5/webcomponents-base/dist/config/Timezone.js\";\nimport getDesigntimePropertyAsArray from \"@ui5/webcomponents-base/dist/util/getDesigntimePropertyAsArray.js\";\n// @ts-ignore\nimport TimezoneUtil from \"./format/TimezoneUtil.js\";\nimport FormatSettings from \"./FormatSettings.js\";\n\nconst emptyFn = () => {};\n\n/**\n * OpenUI5 Configuration Shim\n */\nconst Configuration = {\n\tgetLanguage,\n\tgetCalendarType,\n\tgetSupportedLanguages: () => getDesigntimePropertyAsArray(\"$core-i18n-locales:,ar,bg,ca,cs,da,de,el,en,es,et,fi,fr,hi,hr,hu,it,iw,ja,ko,lt,lv,nl,no,pl,pt,ro,ru,sh,sk,sl,sv,th,tr,uk,vi,zh_CN,zh_TW$\"),\n\tgetOriginInfo: emptyFn,\n\tgetFormatSettings: () => FormatSettings,\n\tgetTimezone: () => getConfigTimezone() || TimezoneUtil.getLocalTimezone() as string,\n\t// Calculate calendar week numbering by active format locale\n\tgetCalendarWeekNumbering: () => \"Default\",\n};\n\nexport default Configuration;\n"]}
|
@@ -14,6 +14,7 @@ declare const Core: {
|
|
14
14
|
getLegacyDateCalendarCustomizing: typeof import("@ui5/webcomponents-base/dist/features/LegacyDateFormats.js").default.getLegacyDateCalendarCustomizing;
|
15
15
|
};
|
16
16
|
getTimezone: () => string;
|
17
|
+
getCalendarWeekNumbering: () => string;
|
17
18
|
};
|
18
19
|
getLibraryResourceBundle: void;
|
19
20
|
getFormatSettings: () => {
|