@ui5/webcomponents-localization 0.0.0-dc606098a → 0.0.0-dcd8e5389
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/.eslintignore +1 -0
- package/.npsrc.json +3 -0
- package/CHANGELOG.md +449 -0
- package/README.md +36 -6
- package/dist/Assets-static.d.ts +1 -0
- package/dist/Assets-static.js +3 -0
- package/dist/Assets-static.js.map +1 -0
- package/dist/Assets.d.ts +1 -0
- package/dist/Assets.js +1 -0
- package/dist/Assets.js.map +1 -0
- package/dist/DateFormat.d.ts +6 -0
- package/dist/DateFormat.js +6 -2
- package/dist/DateFormat.js.map +1 -0
- package/dist/LocaleData.d.ts +6 -0
- package/dist/LocaleData.js +6 -2
- package/dist/LocaleData.js.map +1 -0
- package/dist/dates/CalendarDate.d.ts +43 -0
- package/dist/dates/CalendarDate.js +171 -181
- package/dist/dates/CalendarDate.js.map +1 -0
- package/dist/dates/ExtremeDates.d.ts +5 -0
- package/dist/dates/ExtremeDates.js +29 -0
- package/dist/dates/ExtremeDates.js.map +1 -0
- package/dist/dates/UI5Date.d.ts +6 -0
- package/dist/dates/UI5Date.js +7 -0
- package/dist/dates/UI5Date.js.map +1 -0
- package/dist/dates/UniversalDate.d.ts +47 -0
- package/dist/dates/UniversalDate.js +5 -0
- package/dist/dates/UniversalDate.js.map +1 -0
- package/dist/dates/calculateWeekNumber.d.ts +5 -0
- package/dist/dates/calculateWeekNumber.js +42 -48
- package/dist/dates/calculateWeekNumber.js.map +1 -0
- package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
- package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
- package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
- package/dist/dates/getDaysInMonth.d.ts +3 -0
- package/dist/dates/getDaysInMonth.js +10 -0
- package/dist/dates/getDaysInMonth.js.map +1 -0
- package/dist/dates/getRoundedTimestamp.d.ts +7 -0
- package/dist/dates/getRoundedTimestamp.js +15 -0
- package/dist/dates/getRoundedTimestamp.js.map +1 -0
- package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
- package/dist/dates/getTodayUTCTimestamp.js +9 -0
- package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
- package/dist/dates/modifyDateBy.d.ts +13 -0
- package/dist/dates/modifyDateBy.js +40 -0
- package/dist/dates/modifyDateBy.js.map +1 -0
- package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
- package/dist/dates/transformDateToSecondaryType.js +18 -0
- package/dist/dates/transformDateToSecondaryType.js.map +1 -0
- package/dist/features/calendar/Buddhist.js +1 -0
- package/dist/features/calendar/Buddhist.js.map +1 -0
- package/dist/features/calendar/Gregorian.js +1 -0
- package/dist/features/calendar/Gregorian.js.map +1 -0
- package/dist/features/calendar/Islamic.js +1 -0
- package/dist/features/calendar/Islamic.js.map +1 -0
- package/dist/features/calendar/Japanese.js +1 -0
- package/dist/features/calendar/Japanese.js.map +1 -0
- package/dist/features/calendar/Persian.js +1 -0
- package/dist/features/calendar/Persian.js.map +1 -0
- package/dist/generated/assets/cldr/ar.json +2816 -5904
- package/dist/generated/assets/cldr/ar_EG.json +2816 -5904
- package/dist/generated/assets/cldr/ar_SA.json +2815 -5904
- package/dist/generated/assets/cldr/bg.json +2733 -4977
- package/dist/generated/assets/cldr/ca.json +2680 -4994
- package/dist/generated/assets/cldr/cs.json +2716 -5496
- package/dist/generated/assets/cldr/cy.json +2799 -0
- package/dist/generated/assets/cldr/da.json +2597 -4886
- package/dist/generated/assets/cldr/de.json +2614 -4914
- package/dist/generated/assets/cldr/de_AT.json +2614 -4915
- package/dist/generated/assets/cldr/de_CH.json +2614 -4913
- package/dist/generated/assets/cldr/el.json +2595 -4881
- package/dist/generated/assets/cldr/el_CY.json +2595 -4881
- package/dist/generated/assets/cldr/en.json +2583 -4968
- package/dist/generated/assets/cldr/en_AU.json +2592 -4960
- package/dist/generated/assets/cldr/en_GB.json +2584 -4969
- package/dist/generated/assets/cldr/en_HK.json +2593 -4975
- package/dist/generated/assets/cldr/en_IE.json +2584 -4969
- package/dist/generated/assets/cldr/en_IN.json +2588 -4970
- package/dist/generated/assets/cldr/en_NZ.json +2584 -4969
- package/dist/generated/assets/cldr/en_PG.json +2584 -4970
- package/dist/generated/assets/cldr/en_SG.json +2588 -4971
- package/dist/generated/assets/cldr/en_ZA.json +2584 -4970
- package/dist/generated/assets/cldr/es.json +2640 -4910
- package/dist/generated/assets/cldr/es_AR.json +2645 -4912
- package/dist/generated/assets/cldr/es_BO.json +2645 -4911
- package/dist/generated/assets/cldr/es_CL.json +2645 -4912
- package/dist/generated/assets/cldr/es_CO.json +2644 -4911
- package/dist/generated/assets/cldr/es_MX.json +2645 -4913
- package/dist/generated/assets/cldr/es_PE.json +2645 -4911
- package/dist/generated/assets/cldr/es_UY.json +2645 -4913
- package/dist/generated/assets/cldr/es_VE.json +2645 -4912
- package/dist/generated/assets/cldr/et.json +2599 -4965
- package/dist/generated/assets/cldr/fa.json +2618 -4881
- package/dist/generated/assets/cldr/fi.json +2726 -5006
- package/dist/generated/assets/cldr/fr.json +2590 -4977
- package/dist/generated/assets/cldr/fr_BE.json +2590 -4977
- package/dist/generated/assets/cldr/fr_CA.json +2605 -4971
- package/dist/generated/assets/cldr/fr_CH.json +2607 -4995
- package/dist/generated/assets/cldr/fr_LU.json +2590 -4977
- package/dist/generated/assets/cldr/he.json +2711 -5376
- package/dist/generated/assets/cldr/hi.json +2602 -4827
- package/dist/generated/assets/cldr/hr.json +2652 -4917
- package/dist/generated/assets/cldr/hu.json +2598 -4854
- package/dist/generated/assets/cldr/id.json +2544 -4656
- package/dist/generated/assets/cldr/it.json +2590 -4948
- package/dist/generated/assets/cldr/it_CH.json +2590 -4948
- package/dist/generated/assets/cldr/ja.json +2663 -4828
- package/dist/generated/assets/cldr/kk.json +2589 -4723
- package/dist/generated/assets/cldr/ko.json +2641 -4736
- package/dist/generated/assets/cldr/lt.json +2720 -5479
- package/dist/generated/assets/cldr/lv.json +2644 -5110
- package/dist/generated/assets/cldr/ms.json +2538 -4513
- package/dist/generated/assets/cldr/nb.json +2621 -4975
- package/dist/generated/assets/cldr/nl.json +2601 -4882
- package/dist/generated/assets/cldr/nl_BE.json +2601 -4882
- package/dist/generated/assets/cldr/pl.json +2723 -5174
- package/dist/generated/assets/cldr/pt.json +2607 -4803
- package/dist/generated/assets/cldr/pt_PT.json +2658 -4938
- package/dist/generated/assets/cldr/ro.json +2645 -5088
- package/dist/generated/assets/cldr/ru.json +2704 -5405
- package/dist/generated/assets/cldr/ru_UA.json +2704 -5405
- package/dist/generated/assets/cldr/sk.json +2726 -5368
- package/dist/generated/assets/cldr/sl.json +2688 -5338
- package/dist/generated/assets/cldr/sr.json +2663 -5124
- package/dist/generated/assets/cldr/sr_Latn.json +2668 -0
- package/dist/generated/assets/cldr/sv.json +2631 -5009
- package/dist/generated/assets/cldr/th.json +2635 -4795
- package/dist/generated/assets/cldr/tr.json +2612 -4977
- package/dist/generated/assets/cldr/uk.json +2684 -5351
- package/dist/generated/assets/cldr/vi.json +2555 -4671
- package/dist/generated/assets/cldr/zh_CN.json +2555 -4630
- package/dist/generated/assets/cldr/zh_HK.json +2563 -4638
- package/dist/generated/assets/cldr/zh_SG.json +2562 -4638
- package/dist/generated/assets/cldr/zh_TW.json +2587 -4726
- package/dist/generated/json-imports/LocaleData-static.js +90 -0
- package/dist/generated/json-imports/LocaleData.js +88 -91
- package/dist/getCachedLocaleDataInstance.d.ts +4 -0
- package/dist/getCachedLocaleDataInstance.js +10 -0
- package/dist/getCachedLocaleDataInstance.js.map +1 -0
- package/dist/locale/getLocaleData.d.ts +11 -0
- package/dist/locale/getLocaleData.js +13 -17
- package/dist/locale/getLocaleData.js.map +1 -0
- package/dist/sap/base/Log.js +28 -37
- package/dist/sap/base/assert.js +5 -10
- package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
- package/dist/sap/base/util/LoaderExtensions.js +11 -4
- package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
- package/dist/sap/base/util/array/uniqueSort.js +7 -7
- package/dist/sap/base/util/deepEqual.js +1 -5
- package/dist/sap/ui/base/Interface.js +3 -5
- package/dist/sap/ui/base/Metadata.js +1 -3
- package/dist/sap/ui/base/Object.js +26 -2
- package/dist/sap/ui/core/Configuration.d.ts +17 -0
- package/dist/sap/ui/core/Configuration.js +21 -0
- package/dist/sap/ui/core/Configuration.js.map +1 -0
- package/dist/sap/ui/core/Core.d.ts +26 -0
- package/dist/sap/ui/core/Core.js +7 -32
- package/dist/sap/ui/core/Core.js.map +1 -0
- package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
- package/dist/sap/ui/core/FormatSettings.js +14 -0
- package/dist/sap/ui/core/FormatSettings.js.map +1 -0
- package/dist/sap/ui/core/Locale.js +70 -31
- package/dist/sap/ui/core/LocaleData.js +206 -1525
- package/dist/sap/ui/core/date/Buddhist.js +0 -6
- package/dist/sap/ui/core/date/CalendarUtils.js +36 -0
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +7 -0
- package/dist/sap/ui/core/date/Islamic.js +3 -3
- package/dist/sap/ui/core/date/Japanese.js +4 -4
- package/dist/sap/ui/core/date/UI5Date.js +305 -0
- package/dist/sap/ui/core/date/UniversalDate.js +85 -25
- package/dist/sap/ui/core/format/DateFormat.js +819 -497
- package/dist/sap/ui/core/format/TimezoneUtil.js +89 -0
- package/package-scripts.cjs +37 -0
- package/package.json +14 -13
- package/tsconfig.json +14 -0
- package/used-modules.txt +5 -1
- package/package-scripts.js +0 -31
- package/src/Assets.js +0 -2
- package/src/DateFormat.js +0 -3
- package/src/LocaleData.js +0 -3
- package/src/dates/CalendarDate.js +0 -203
- package/src/dates/calculateWeekNumber.js +0 -51
- package/src/locale/getLocaleData.js +0 -27
- package/src/sap/base/util/LoaderExtensions.js +0 -7
- package/src/sap/ui/core/Core.js +0 -38
- /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
- /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
- /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
- /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
- /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
var TimezoneUtil = {};
|
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
|
+
TimezoneUtil.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
|
+
TimezoneUtil.convertToTimezone = function (oDate, sTargetTimezone) {
|
56
|
+
var oFormatParts = this._getParts(oDate, sTargetTimezone);
|
57
|
+
return TimezoneUtil._getDateFromParts(oFormatParts);
|
58
|
+
};
|
59
|
+
TimezoneUtil._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
|
+
TimezoneUtil._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
|
+
TimezoneUtil.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
|
+
TimezoneUtil.getLocalTimezone = function () {
|
83
|
+
if (sLocalTimezone) {
|
84
|
+
return sLocalTimezone;
|
85
|
+
}
|
86
|
+
sLocalTimezone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
87
|
+
return sLocalTimezone;
|
88
|
+
};
|
89
|
+
export default TimezoneUtil;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
const resolve = require("resolve");
|
2
|
+
const copyUsedModules = resolve.sync("@ui5/webcomponents-tools/lib/copy-list/index.js");
|
3
|
+
const replaceGlobalCore = resolve.sync("@ui5/webcomponents-tools/lib/replace-global-core/index.js");
|
4
|
+
const esmAbsToRel = resolve.sync("@ui5/webcomponents-tools/lib/esm-abs-to-rel/index.js");
|
5
|
+
|
6
|
+
const scripts = {
|
7
|
+
clean: "rimraf dist",
|
8
|
+
lint: "eslint .",
|
9
|
+
build: {
|
10
|
+
"default": "nps lint clean copy.used-modules copy.cldr copy.overlay build.replace-amd build.replace-export-true build.replace-export-false build.amd-to-es6 build.replace-global-core-usage build.esm-abs-to-rel build.jsonImports build.typescript copy.src",
|
11
|
+
"replace-amd": "replace-in-file sap.ui.define define dist/**/*.js",
|
12
|
+
"replace-export-true": `replace-in-file ", /* bExport= */ true" "" dist/**/*.js`,
|
13
|
+
"replace-export-false": `replace-in-file ", /* bExport= */ false" "" dist/**/*.js`,
|
14
|
+
"amd-to-es6": "amdtoes6 --src=dist --replace --glob=**/*.js",
|
15
|
+
"replace-global-core-usage": `node "${replaceGlobalCore}" dist/`,
|
16
|
+
"esm-abs-to-rel": `node "${esmAbsToRel}" dist/`,
|
17
|
+
typescript: "tsc",
|
18
|
+
jsonImports: "node ./lib/generate-json-imports/cldr.js"
|
19
|
+
},
|
20
|
+
typescript: "tsc",
|
21
|
+
copy: {
|
22
|
+
"used-modules": `node "${copyUsedModules}" ./used-modules.txt dist/`,
|
23
|
+
cldr: `node ./lib/copy-and-strip-cldr/index.js "../../node_modules/@openui5/sap.ui.core/src/sap/ui/core/cldr/" dist/generated/assets/cldr/`,
|
24
|
+
overlay: `copy-and-watch "overlay/**/*.js" dist/`,
|
25
|
+
src: `copy-and-watch "src/**/*.js" dist/`,
|
26
|
+
},
|
27
|
+
watch: {
|
28
|
+
default: 'concurrently "nps watch.src" "nps watch.typescript" ',
|
29
|
+
typescript: "tsc --watch",
|
30
|
+
src: `nps "copy.src --watch --skip-initial-copy"`,
|
31
|
+
},
|
32
|
+
start: "nps watch",
|
33
|
+
};
|
34
|
+
|
35
|
+
module.exports = {
|
36
|
+
scripts,
|
37
|
+
};
|
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-localization",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-dcd8e5389",
|
4
4
|
"description": "Localization for UI5 Web Components",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
7
|
+
"type": "module",
|
7
8
|
"keywords": [
|
8
9
|
"openui5",
|
9
10
|
"sapui5",
|
@@ -14,6 +15,11 @@
|
|
14
15
|
"url": "https://github.com/SAP/ui5-webcomponents.git",
|
15
16
|
"directory": "packages/localization"
|
16
17
|
},
|
18
|
+
"exports": {
|
19
|
+
"./dist/*": "./dist/*",
|
20
|
+
"./package.json": "./package.json",
|
21
|
+
"./*": "./dist/*"
|
22
|
+
},
|
17
23
|
"scripts": {
|
18
24
|
"clean": "nps clean",
|
19
25
|
"lint": "nps lint",
|
@@ -22,19 +28,14 @@
|
|
22
28
|
"prepublishOnly": "npm run clean && npm run build"
|
23
29
|
},
|
24
30
|
"devDependencies": {
|
25
|
-
"@
|
26
|
-
"@
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"esprima": "^4.0.1",
|
31
|
-
"glob": "^7.1.3",
|
32
|
-
"mkdirp": "^0.5.1",
|
33
|
-
"path-exists-cli": "^1.0.0",
|
34
|
-
"replace-in-file": "^3.4.2",
|
35
|
-
"rimraf": "^2.6.2"
|
31
|
+
"@openui5/sap.ui.core": "1.112.0",
|
32
|
+
"@ui5/webcomponents-tools": "0.0.0-dcd8e5389",
|
33
|
+
"chromedriver": "112.0.0",
|
34
|
+
"mkdirp": "^1.0.4",
|
35
|
+
"resolve": "^1.20.0"
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
|
-
"@
|
38
|
+
"@types/openui5": "^1.112.0",
|
39
|
+
"@ui5/webcomponents-base": "0.0.0-dcd8e5389"
|
39
40
|
}
|
40
41
|
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"include": ["src/**/*"],
|
3
|
+
"compilerOptions": {
|
4
|
+
"target": "ES2021",
|
5
|
+
// Generate d.ts files
|
6
|
+
"declaration": true,
|
7
|
+
"outDir": "dist",
|
8
|
+
"skipLibCheck": true,
|
9
|
+
"sourceMap": true,
|
10
|
+
"inlineSources": true,
|
11
|
+
"strict": true,
|
12
|
+
"moduleResolution": "node",
|
13
|
+
},
|
14
|
+
}
|
package/used-modules.txt
CHANGED
@@ -17,9 +17,13 @@ sap/ui/core/CalendarType.js
|
|
17
17
|
sap/ui/core/Locale.js
|
18
18
|
sap/ui/core/LocaleData.js
|
19
19
|
sap/ui/core/date/Buddhist.js
|
20
|
+
sap/ui/core/date/CalendarUtils.js
|
21
|
+
sap/ui/core/date/CalendarWeekNumbering.js
|
20
22
|
sap/ui/core/date/Gregorian.js
|
21
23
|
sap/ui/core/date/Islamic.js
|
22
24
|
sap/ui/core/date/Japanese.js
|
23
25
|
sap/ui/core/date/Persian.js
|
26
|
+
sap/ui/core/date/UI5Date.js
|
24
27
|
sap/ui/core/date/UniversalDate.js
|
25
|
-
sap/ui/core/format/
|
28
|
+
sap/ui/core/format/TimezoneUtil.js
|
29
|
+
sap/ui/core/format/DateFormat.js
|
package/package-scripts.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
const scripts = {
|
2
|
-
clean: "rimraf dist",
|
3
|
-
lint: "eslint . --config config/.eslintrc.js",
|
4
|
-
build: {
|
5
|
-
"default": "path-exists dist/ || nps build.all",
|
6
|
-
all: "nps lint clean copy.used-modules copy.cldr copy.overlay build.replace-amd build.replace-export-true build.replace-export-false build.amd-to-es6 build.replace-global-core-usage build.esm-abs-to-rel build.jsonImports copy.src",
|
7
|
-
"replace-amd": "replace-in-file sap.ui.define define dist/**/*.js",
|
8
|
-
"replace-export-true": `replace-in-file ", /* bExport= */ true" "" dist/**/*.js`,
|
9
|
-
"replace-export-false": `replace-in-file ", /* bExport= */ false" "" dist/**/*.js`,
|
10
|
-
"amd-to-es6": "amdtoes6 --src=dist --replace --glob=**/*.js",
|
11
|
-
"replace-global-core-usage": "node ./lib/replace-global-core/index.js dist/",
|
12
|
-
"esm-abs-to-rel": "node ./lib/esm-abs-to-rel/index.js dist/",
|
13
|
-
jsonImports: "node ./lib/generate-json-imports/cldr.js",
|
14
|
-
},
|
15
|
-
copy: {
|
16
|
-
"used-modules": "node ./lib/copy-list/index.js ./used-modules.txt dist/",
|
17
|
-
cldr: `copy-and-watch "../../node_modules/@openui5/sap.ui.core/src/sap/ui/core/cldr/*.json" dist/generated/assets/cldr/`,
|
18
|
-
overlay: `copy-and-watch "overlay/**/*.js" dist/`,
|
19
|
-
src: `copy-and-watch "src/**/*.js" dist/`,
|
20
|
-
},
|
21
|
-
watch: {
|
22
|
-
default: 'nps watch.src',
|
23
|
-
src: `nps "copy.src --watch --skip-initial-copy"`,
|
24
|
-
},
|
25
|
-
start: "nps watch",
|
26
|
-
};
|
27
|
-
|
28
|
-
|
29
|
-
module.exports = {
|
30
|
-
scripts,
|
31
|
-
};
|
package/src/Assets.js
DELETED
package/src/DateFormat.js
DELETED
package/src/LocaleData.js
DELETED
@@ -1,203 +0,0 @@
|
|
1
|
-
import UniversalDate from "../sap/ui/core/date/UniversalDate.js";
|
2
|
-
|
3
|
-
class CalendarDate {
|
4
|
-
constructor() {
|
5
|
-
let aArgs = arguments, // eslint-disable-line
|
6
|
-
oJSDate,
|
7
|
-
oNow,
|
8
|
-
sCalendarType;
|
9
|
-
|
10
|
-
switch (aArgs.length) {
|
11
|
-
case 0: // defaults to the current date
|
12
|
-
oNow = new Date();
|
13
|
-
return this.constructor(oNow.getFullYear(), oNow.getMonth(), oNow.getDate());
|
14
|
-
|
15
|
-
case 1: // CalendarDate
|
16
|
-
case 2: // CalendarDate, sCalendarType
|
17
|
-
if (!(aArgs[0] instanceof CalendarDate)) {
|
18
|
-
throw new Error("Invalid arguments: the first argument must be of type sap.ui.unified.calendar.CalendarDate.");
|
19
|
-
}
|
20
|
-
sCalendarType = aArgs[1] ? aArgs[1] : aArgs[0]._oUDate.sCalendarType;
|
21
|
-
// Use source.valueOf() (returns the same point of time regardless calendar type) instead of
|
22
|
-
// source's getters to avoid non-gregorian Year, Month and Date may be used to construct a Gregorian date
|
23
|
-
oJSDate = new Date(aArgs[0].valueOf());
|
24
|
-
|
25
|
-
// Make this date really local. Now getters are safe.
|
26
|
-
oJSDate.setFullYear(oJSDate.getUTCFullYear(), oJSDate.getUTCMonth(), oJSDate.getUTCDate());
|
27
|
-
oJSDate.setHours(oJSDate.getUTCHours(), oJSDate.getUTCMinutes(), oJSDate.getUTCSeconds(), oJSDate.getUTCMilliseconds());
|
28
|
-
|
29
|
-
this._oUDate = createUniversalUTCDate(oJSDate, sCalendarType);
|
30
|
-
break;
|
31
|
-
|
32
|
-
case 3: // year, month, date
|
33
|
-
case 4: // year, month, date, sCalendarType
|
34
|
-
checkNumericLike(aArgs[0], `Invalid year: ${aArgs[0]}`);
|
35
|
-
checkNumericLike(aArgs[1], `Invalid month: ${aArgs[1]}`);
|
36
|
-
checkNumericLike(aArgs[2], `Invalid date: ${aArgs[2]}`);
|
37
|
-
|
38
|
-
oJSDate = new Date(0, 0, 1);
|
39
|
-
oJSDate.setFullYear(aArgs[0], aArgs[1], aArgs[2]); // 2 digits year is not supported. If so, it is considered as full year as well.
|
40
|
-
|
41
|
-
if (aArgs[3]) {
|
42
|
-
sCalendarType = aArgs[3];
|
43
|
-
}
|
44
|
-
this._oUDate = createUniversalUTCDate(oJSDate, sCalendarType);
|
45
|
-
break;
|
46
|
-
|
47
|
-
default:
|
48
|
-
throw new Error(`${"Invalid arguments. Accepted arguments are: 1) oCalendarDate, (optional)calendarType"
|
49
|
-
+ "or 2) year, month, date, (optional) calendarType"}${aArgs}`);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
getYear() {
|
54
|
-
return this._oUDate.getUTCFullYear();
|
55
|
-
}
|
56
|
-
|
57
|
-
setYear(year) {
|
58
|
-
checkNumericLike(year, `Invalid year: ${year}`);
|
59
|
-
this._oUDate.setUTCFullYear(year);
|
60
|
-
return this;
|
61
|
-
}
|
62
|
-
|
63
|
-
getMonth() {
|
64
|
-
return this._oUDate.getUTCMonth();
|
65
|
-
}
|
66
|
-
|
67
|
-
setMonth(month) {
|
68
|
-
checkNumericLike(month, `Invalid month: ${month}`);
|
69
|
-
this._oUDate.setUTCMonth(month);
|
70
|
-
return this;
|
71
|
-
}
|
72
|
-
|
73
|
-
getDate() {
|
74
|
-
return this._oUDate.getUTCDate();
|
75
|
-
}
|
76
|
-
|
77
|
-
setDate(date) {
|
78
|
-
checkNumericLike(date, `Invalid date: ${date}`);
|
79
|
-
this._oUDate.setUTCDate(date);
|
80
|
-
return this;
|
81
|
-
}
|
82
|
-
|
83
|
-
getDay() {
|
84
|
-
return this._oUDate.getUTCDay();
|
85
|
-
}
|
86
|
-
|
87
|
-
getCalendarType() {
|
88
|
-
return this._oUDate.sCalendarType;
|
89
|
-
}
|
90
|
-
|
91
|
-
isBefore(oCalendarDate) {
|
92
|
-
checkCalendarDate(oCalendarDate);
|
93
|
-
return this.valueOf() < oCalendarDate.valueOf();
|
94
|
-
}
|
95
|
-
|
96
|
-
isAfter(oCalendarDate) {
|
97
|
-
checkCalendarDate(oCalendarDate);
|
98
|
-
return this.valueOf() > oCalendarDate.valueOf();
|
99
|
-
}
|
100
|
-
|
101
|
-
isSameOrBefore(oCalendarDate) {
|
102
|
-
checkCalendarDate(oCalendarDate);
|
103
|
-
return this.valueOf() <= oCalendarDate.valueOf();
|
104
|
-
}
|
105
|
-
|
106
|
-
isSameOrAfter(oCalendarDate) {
|
107
|
-
checkCalendarDate(oCalendarDate);
|
108
|
-
return this.valueOf() >= oCalendarDate.valueOf();
|
109
|
-
}
|
110
|
-
|
111
|
-
isSame(oCalendarDate) {
|
112
|
-
checkCalendarDate(oCalendarDate);
|
113
|
-
return this.valueOf() === oCalendarDate.valueOf();
|
114
|
-
}
|
115
|
-
|
116
|
-
toLocalJSDate() {
|
117
|
-
// Use this._oUDate.getTime()(returns the same point of time regardless calendar type) instead of
|
118
|
-
// this._oUDate's getters to avoid non-gregorian Year, Month and Date to be used to construct a Gregorian date
|
119
|
-
const oLocalDate = new Date(this._oUDate.getTime());
|
120
|
-
|
121
|
-
// Make this date really local. Now getters are safe.
|
122
|
-
oLocalDate.setFullYear(oLocalDate.getUTCFullYear(), oLocalDate.getUTCMonth(), oLocalDate.getUTCDate());
|
123
|
-
oLocalDate.setHours(0, 0, 0, 0);
|
124
|
-
|
125
|
-
return oLocalDate;
|
126
|
-
}
|
127
|
-
|
128
|
-
toUTCJSDate() {
|
129
|
-
// Use this._oUDate.getTime()(returns the same point of time regardless calendar type) instead of
|
130
|
-
// this._oUDate's getters to avoid non-gregorian Year, Month and Date to be used to construct a Gregorian date
|
131
|
-
const oUTCDate = new Date(this._oUDate.getTime());
|
132
|
-
oUTCDate.setUTCHours(0, 0, 0, 0);
|
133
|
-
|
134
|
-
return oUTCDate;
|
135
|
-
}
|
136
|
-
|
137
|
-
toString() {
|
138
|
-
return `${this._oUDate.sCalendarType}: ${this.getYear()}/${this.getMonth() + 1}/${this.getDate()}`;
|
139
|
-
}
|
140
|
-
|
141
|
-
valueOf() {
|
142
|
-
return this._oUDate.getTime();
|
143
|
-
}
|
144
|
-
|
145
|
-
static fromLocalJSDate(oJSDate, sCalendarType) {
|
146
|
-
// Cross frame check for a date should be performed here otherwise setDateValue would fail in OPA tests
|
147
|
-
// because Date object in the test is different than the Date object in the application (due to the iframe).
|
148
|
-
// We can use jQuery.type or this method:
|
149
|
-
function isValidDate(date) {
|
150
|
-
return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date); // eslint-disable-line
|
151
|
-
}
|
152
|
-
if (!isValidDate(oJSDate)) {
|
153
|
-
throw new Error(`Date parameter must be a JavaScript Date object: [${oJSDate}].`);
|
154
|
-
}
|
155
|
-
return new CalendarDate(oJSDate.getFullYear(), oJSDate.getMonth(), oJSDate.getDate(), sCalendarType);
|
156
|
-
}
|
157
|
-
|
158
|
-
static fromTimestamp(iTimestamp, sCalendarType) {
|
159
|
-
const oCalDate = new CalendarDate(0, 0, 1);
|
160
|
-
oCalDate._oUDate = UniversalDate.getInstance(new Date(iTimestamp), sCalendarType);
|
161
|
-
return oCalDate;
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
function createUniversalUTCDate(oDate, sCalendarType) {
|
166
|
-
if (sCalendarType) {
|
167
|
-
return UniversalDate.getInstance(createUTCDate(oDate), sCalendarType);
|
168
|
-
}
|
169
|
-
return new UniversalDate(createUTCDate(oDate).getTime());
|
170
|
-
}
|
171
|
-
|
172
|
-
/**
|
173
|
-
* Creates a JavaScript UTC Date corresponding to the given JavaScript Date.
|
174
|
-
* @param {Date} oDate JavaScript date object. Time related information is cut.
|
175
|
-
* @returns {Date} JavaScript date created from the date object, but this time considered as UTC date information.
|
176
|
-
*/
|
177
|
-
function createUTCDate(oDate) {
|
178
|
-
const oUTCDate = new Date(Date.UTC(0, 0, 1));
|
179
|
-
|
180
|
-
oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
|
181
|
-
|
182
|
-
return oUTCDate;
|
183
|
-
}
|
184
|
-
|
185
|
-
function checkCalendarDate(oCalendarDate) {
|
186
|
-
if (!(oCalendarDate instanceof CalendarDate)) {
|
187
|
-
throw new Error(`Invalid calendar date: [${oCalendarDate}]. Expected: sap.ui.unified.calendar.CalendarDate`);
|
188
|
-
}
|
189
|
-
}
|
190
|
-
|
191
|
-
/**
|
192
|
-
* Verifies the given value is numeric like, i.e. 3, "3" and throws an error if it is not.
|
193
|
-
* @param {any} value The value of any type to check. If null or undefined, this method throws an error.
|
194
|
-
* @param {string} message The message to be used if an error is to be thrown
|
195
|
-
* @throws will throw an error if the value is null or undefined or is not like a number
|
196
|
-
*/
|
197
|
-
function checkNumericLike(value, message) {
|
198
|
-
if (value === undefined || value === Infinity || isNaN(value)) { // eslint-disable-line
|
199
|
-
throw message;
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|
203
|
-
export default CalendarDate;
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import UniversalDate from "../sap/ui/core/date/UniversalDate.js";
|
2
|
-
|
3
|
-
const calculateWeekNumber = (confFirstDayOfWeek, oDate, iYear, oLocale, oLocaleData) => {
|
4
|
-
let iWeekNum = 0;
|
5
|
-
let iWeekDay = 0;
|
6
|
-
const iFirstDayOfWeek = Number.isInteger(confFirstDayOfWeek) ? confFirstDayOfWeek : oLocaleData.getFirstDayOfWeek();
|
7
|
-
|
8
|
-
// search Locale for containing "en-US", since sometimes
|
9
|
-
// when any user settings have been defined, subtag "sapufmt" is added to the locale name
|
10
|
-
// this is described inside sap.ui.core.Configuration file
|
11
|
-
if (oLocale && (oLocale.getLanguage() === "en" && oLocale.getRegion() === "US")) {
|
12
|
-
/*
|
13
|
-
* in US the week starts with Sunday
|
14
|
-
* The first week of the year starts with January 1st. But Dec. 31 is still in the last year
|
15
|
-
* So the week beginning in December and ending in January has 2 week numbers
|
16
|
-
*/
|
17
|
-
const oJanFirst = new UniversalDate(oDate.getTime());
|
18
|
-
oJanFirst.setUTCFullYear(iYear, 0, 1);
|
19
|
-
iWeekDay = oJanFirst.getUTCDay();
|
20
|
-
|
21
|
-
// get the date for the same weekday like jan 1.
|
22
|
-
const oCheckDate = new UniversalDate(oDate.getTime());
|
23
|
-
oCheckDate.setUTCDate(oCheckDate.getUTCDate() - oCheckDate.getUTCDay() + iWeekDay);
|
24
|
-
|
25
|
-
iWeekNum = Math.round((oCheckDate.getTime() - oJanFirst.getTime()) / 86400000 / 7) + 1;
|
26
|
-
} else {
|
27
|
-
// normally the first week of the year is the one where the first Thursday of the year is
|
28
|
-
// find Thursday of this week
|
29
|
-
// if the checked day is before the 1. day of the week use a day of the previous week to check
|
30
|
-
const oThursday = new UniversalDate(oDate.getTime());
|
31
|
-
oThursday.setUTCDate(oThursday.getUTCDate() - iFirstDayOfWeek);
|
32
|
-
iWeekDay = oThursday.getUTCDay();
|
33
|
-
oThursday.setUTCDate(oThursday.getUTCDate() - iWeekDay + 4);
|
34
|
-
|
35
|
-
const oFirstDayOfYear = new UniversalDate(oThursday.getTime());
|
36
|
-
oFirstDayOfYear.setUTCMonth(0, 1);
|
37
|
-
iWeekDay = oFirstDayOfYear.getUTCDay();
|
38
|
-
let iAddDays = 0;
|
39
|
-
if (iWeekDay > 4) {
|
40
|
-
iAddDays = 7; // first day of year is after Thursday, so first Thursday is in the next week
|
41
|
-
}
|
42
|
-
const oFirstThursday = new UniversalDate(oFirstDayOfYear.getTime());
|
43
|
-
oFirstThursday.setUTCDate(1 - iWeekDay + 4 + iAddDays);
|
44
|
-
|
45
|
-
iWeekNum = Math.round((oThursday.getTime() - oFirstThursday.getTime()) / 86400000 / 7) + 1;
|
46
|
-
}
|
47
|
-
|
48
|
-
return iWeekNum;
|
49
|
-
};
|
50
|
-
|
51
|
-
export default calculateWeekNumber;
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { fetchCldr } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js";
|
2
|
-
import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
|
3
|
-
import LocaleData from "../sap/ui/core/LocaleData.js";
|
4
|
-
|
5
|
-
const instances = new Map();
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Fetches and returns а LocaleData object for the required locale
|
9
|
-
* For more information on this object's API, please see:
|
10
|
-
* https://ui5.sap.com/#/api/sap.ui.core.LocaleData
|
11
|
-
*
|
12
|
-
* @param lang - if left empty, will use the configured/current locale
|
13
|
-
* @returns {LocaleData}
|
14
|
-
*/
|
15
|
-
const getLocaleData = async lang => {
|
16
|
-
const locale = getLocale(lang);
|
17
|
-
const localeLang = locale.getLanguage();
|
18
|
-
|
19
|
-
if (!instances.has(localeLang)) {
|
20
|
-
await fetchCldr(locale.getLanguage(), locale.getRegion(), locale.getScript());
|
21
|
-
instances.set(localeLang, LocaleData.getInstance(locale));
|
22
|
-
}
|
23
|
-
|
24
|
-
return instances.get(localeLang);
|
25
|
-
};
|
26
|
-
|
27
|
-
export default getLocaleData;
|
package/src/sap/ui/core/Core.js
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
|
2
|
-
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
|
3
|
-
import getDesigntimePropertyAsArray from "@ui5/webcomponents-base/dist/util/getDesigntimePropertyAsArray.js";
|
4
|
-
import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
|
5
|
-
|
6
|
-
const emptyFn = () => {};
|
7
|
-
|
8
|
-
/**
|
9
|
-
* OpenUI5 FormatSettings shim
|
10
|
-
*/
|
11
|
-
const FormatSettings = {
|
12
|
-
getFormatLocale: getLocale,
|
13
|
-
getLegacyDateFormat: emptyFn,
|
14
|
-
getLegacyDateCalendarCustomizing: emptyFn,
|
15
|
-
getCustomLocaleData: emptyFn,
|
16
|
-
};
|
17
|
-
|
18
|
-
/**
|
19
|
-
* OpenUI5 Configuration Shim
|
20
|
-
*/
|
21
|
-
const Configuration = {
|
22
|
-
getLanguage,
|
23
|
-
getCalendarType,
|
24
|
-
getSupportedLanguages: () => 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$"),
|
25
|
-
getOriginInfo: emptyFn,
|
26
|
-
getFormatSettings: () => FormatSettings,
|
27
|
-
};
|
28
|
-
|
29
|
-
/**
|
30
|
-
* OpenUI5 Core shim
|
31
|
-
*/
|
32
|
-
const Core = {
|
33
|
-
getConfiguration: () => Configuration,
|
34
|
-
getLibraryResourceBundle: emptyFn(),
|
35
|
-
getFormatSettings: () => FormatSettings,
|
36
|
-
};
|
37
|
-
|
38
|
-
export default Core;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|