@ui5/webcomponents-localization 0.0.0-cf069fb29 → 0.0.0-d4d43327a
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 +224 -0
- package/README.md +5 -6
- package/dist/Assets-static.d.ts +1 -0
- package/dist/Assets-static.js +1 -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 +41 -0
- package/dist/dates/CalendarDate.js +170 -201
- package/dist/dates/CalendarDate.js.map +1 -0
- package/dist/dates/ExtremeDates.d.ts +5 -0
- package/dist/dates/ExtremeDates.js +25 -35
- package/dist/dates/ExtremeDates.js.map +1 -0
- package/dist/dates/UniversalDate.d.ts +46 -0
- package/dist/dates/UniversalDate.js +5 -0
- package/dist/dates/UniversalDate.js.map +1 -0
- package/dist/dates/calculateWeekNumber.d.ts +4 -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 +9 -9
- package/dist/dates/getRoundedTimestamp.js.map +1 -0
- package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
- package/dist/dates/getTodayUTCTimestamp.js +2 -3
- package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
- package/dist/dates/modifyDateBy.d.ts +13 -0
- package/dist/dates/modifyDateBy.js +27 -29
- package/dist/dates/modifyDateBy.js.map +1 -0
- package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
- package/dist/dates/transformDateToSecondaryType.js +17 -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 +799 -1
- package/dist/generated/assets/cldr/ar_EG.json +799 -1
- package/dist/generated/assets/cldr/ar_SA.json +799 -1
- package/dist/generated/assets/cldr/bg.json +764 -1
- package/dist/generated/assets/cldr/ca.json +798 -1
- package/dist/generated/assets/cldr/cs.json +797 -1
- package/dist/generated/assets/cldr/cy.json +729 -1
- package/dist/generated/assets/cldr/da.json +764 -1
- package/dist/generated/assets/cldr/de.json +798 -1
- package/dist/generated/assets/cldr/de_AT.json +798 -1
- package/dist/generated/assets/cldr/de_CH.json +798 -1
- package/dist/generated/assets/cldr/el.json +697 -1
- package/dist/generated/assets/cldr/el_CY.json +697 -1
- package/dist/generated/assets/cldr/en.json +763 -2
- package/dist/generated/assets/cldr/en_AU.json +764 -2
- package/dist/generated/assets/cldr/en_GB.json +763 -1
- package/dist/generated/assets/cldr/en_HK.json +763 -1
- package/dist/generated/assets/cldr/en_IE.json +763 -1
- package/dist/generated/assets/cldr/en_IN.json +763 -1
- package/dist/generated/assets/cldr/en_NZ.json +763 -1
- package/dist/generated/assets/cldr/en_PG.json +763 -1
- package/dist/generated/assets/cldr/en_SG.json +763 -1
- package/dist/generated/assets/cldr/en_ZA.json +763 -1
- package/dist/generated/assets/cldr/es.json +730 -1
- package/dist/generated/assets/cldr/es_AR.json +730 -1
- package/dist/generated/assets/cldr/es_BO.json +733 -4
- package/dist/generated/assets/cldr/es_CL.json +733 -4
- package/dist/generated/assets/cldr/es_CO.json +730 -1
- package/dist/generated/assets/cldr/es_MX.json +733 -4
- package/dist/generated/assets/cldr/es_PE.json +733 -4
- package/dist/generated/assets/cldr/es_UY.json +733 -4
- package/dist/generated/assets/cldr/es_VE.json +732 -3
- package/dist/generated/assets/cldr/et.json +763 -1
- package/dist/generated/assets/cldr/fa.json +765 -1
- package/dist/generated/assets/cldr/fi.json +797 -1
- package/dist/generated/assets/cldr/fr.json +763 -1
- package/dist/generated/assets/cldr/fr_BE.json +763 -1
- package/dist/generated/assets/cldr/fr_CA.json +763 -1
- package/dist/generated/assets/cldr/fr_CH.json +763 -1
- package/dist/generated/assets/cldr/fr_LU.json +763 -1
- package/dist/generated/assets/cldr/he.json +798 -1
- package/dist/generated/assets/cldr/hi.json +730 -1
- package/dist/generated/assets/cldr/hr.json +763 -1
- package/dist/generated/assets/cldr/hu.json +831 -1
- package/dist/generated/assets/cldr/id.json +763 -1
- package/dist/generated/assets/cldr/it.json +763 -1
- package/dist/generated/assets/cldr/it_CH.json +763 -1
- package/dist/generated/assets/cldr/ja.json +797 -1
- package/dist/generated/assets/cldr/kk.json +763 -1
- package/dist/generated/assets/cldr/ko.json +797 -1
- package/dist/generated/assets/cldr/lt.json +763 -1
- package/dist/generated/assets/cldr/lv.json +763 -1
- package/dist/generated/assets/cldr/ms.json +731 -1
- package/dist/generated/assets/cldr/nb.json +764 -1
- package/dist/generated/assets/cldr/nl.json +730 -1
- package/dist/generated/assets/cldr/nl_BE.json +730 -1
- package/dist/generated/assets/cldr/pl.json +797 -1
- package/dist/generated/assets/cldr/pt.json +763 -1
- package/dist/generated/assets/cldr/pt_PT.json +763 -1
- package/dist/generated/assets/cldr/ro.json +763 -1
- package/dist/generated/assets/cldr/ru.json +763 -1
- package/dist/generated/assets/cldr/ru_UA.json +763 -1
- package/dist/generated/assets/cldr/sk.json +797 -1
- package/dist/generated/assets/cldr/sl.json +797 -1
- package/dist/generated/assets/cldr/sr.json +763 -1
- package/dist/generated/assets/cldr/sr_Latn.json +763 -1
- package/dist/generated/assets/cldr/sv.json +764 -1
- package/dist/generated/assets/cldr/th.json +831 -1
- package/dist/generated/assets/cldr/tr.json +831 -1
- package/dist/generated/assets/cldr/uk.json +763 -1
- package/dist/generated/assets/cldr/vi.json +763 -1
- package/dist/generated/assets/cldr/zh_CN.json +799 -2
- package/dist/generated/assets/cldr/zh_HK.json +799 -2
- package/dist/generated/assets/cldr/zh_SG.json +799 -2
- package/dist/generated/assets/cldr/zh_TW.json +798 -1
- package/dist/generated/json-imports/LocaleData-static.js +2 -1
- package/dist/generated/json-imports/LocaleData.js +2 -1
- package/dist/getCachedLocaleDataInstance.d.ts +4 -0
- package/dist/getCachedLocaleDataInstance.js +6 -9
- 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 -29
- package/dist/sap/base/assert.js +5 -6
- package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
- package/dist/sap/base/util/LoaderExtensions.js +9 -12
- package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
- package/dist/sap/ui/core/Configuration.d.ts +17 -0
- package/dist/sap/ui/core/Configuration.js +20 -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 +13 -0
- package/dist/sap/ui/core/LocaleData.js +107 -6
- 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/UniversalDate.js +79 -22
- package/dist/sap/ui/core/format/DateFormat.js +496 -201
- package/dist/sap/ui/core/format/TimezoneUtil.js +94 -0
- package/package-scripts.js +5 -7
- package/package.json +6 -5
- package/src/DateFormat.ts +8 -0
- package/src/LocaleData.ts +8 -0
- package/src/dates/{CalendarDate.js → CalendarDate.ts} +43 -34
- package/src/dates/{ExtremeDates.js → ExtremeDates.ts} +6 -5
- package/src/dates/UniversalDate.ts +51 -0
- package/src/dates/{calculateWeekNumber.js → calculateWeekNumber.ts} +5 -3
- package/src/dates/convertMonthNumbersToMonthNames.ts +34 -0
- package/src/dates/getDaysInMonth.ts +11 -0
- package/src/dates/{getRoundedTimestamp.js → getRoundedTimestamp.ts} +3 -3
- package/src/dates/getTodayUTCTimestamp.ts +10 -0
- package/src/dates/{modifyDateBy.js → modifyDateBy.ts} +1 -1
- package/src/dates/transformDateToSecondaryType.ts +21 -0
- package/src/features/calendar/Buddhist.ts +1 -0
- package/src/features/calendar/Gregorian.ts +1 -0
- package/src/features/calendar/Islamic.ts +1 -0
- package/src/features/calendar/Japanese.ts +1 -0
- package/src/features/calendar/Persian.ts +1 -0
- package/src/getCachedLocaleDataInstance.ts +15 -0
- package/src/locale/{getLocaleData.js → getLocaleData.ts} +9 -8
- package/src/sap/base/util/{LoaderExtensions.js → LoaderExtensions.ts} +1 -1
- package/src/sap/ui/core/{Core.js → Configuration.ts} +5 -21
- package/src/sap/ui/core/Core.ts +15 -0
- package/src/sap/ui/core/FormatSettings.ts +16 -0
- package/tsconfig.json +13 -0
- package/used-modules.txt +4 -1
- package/hash.txt +0 -1
- package/src/DateFormat.js +0 -3
- package/src/LocaleData.js +0 -3
- package/src/dates/getTodayUTCTimestamp.js +0 -9
- package/src/getCachedLocaleDataInstance.js +0 -13
- /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
- /package/src/{Assets-static.js → Assets-static.ts} +0 -0
- /package/src/{Assets.js → Assets.ts} +0 -0
@@ -0,0 +1,94 @@
|
|
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
|
+
};
|
25
|
+
var oInstance = new Intl.DateTimeFormat("en-US", oOptions);
|
26
|
+
if (this._oCache.size === this._iCacheLimit) {
|
27
|
+
this._oCache = new Map();
|
28
|
+
}
|
29
|
+
this._oCache.set(sTimezone, oInstance);
|
30
|
+
return oInstance;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
TimezoneUtil.isValidTimezone = function (sTimezone) {
|
34
|
+
if (!sTimezone) {
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
if (Intl.supportedValuesOf) {
|
38
|
+
try {
|
39
|
+
aSupportedTimezoneIDs = aSupportedTimezoneIDs || Intl.supportedValuesOf("timeZone");
|
40
|
+
if (aSupportedTimezoneIDs.includes(sTimezone)) {
|
41
|
+
return true;
|
42
|
+
}
|
43
|
+
} catch (oError) {
|
44
|
+
aSupportedTimezoneIDs = [];
|
45
|
+
}
|
46
|
+
}
|
47
|
+
try {
|
48
|
+
oIntlDateTimeFormatCache.get(sTimezone);
|
49
|
+
return true;
|
50
|
+
} catch (oError) {
|
51
|
+
return false;
|
52
|
+
}
|
53
|
+
};
|
54
|
+
TimezoneUtil.convertToTimezone = function (oDate, sTargetTimezone) {
|
55
|
+
var oFormatParts = this._getParts(oDate, sTargetTimezone);
|
56
|
+
return TimezoneUtil._getDateFromParts(oFormatParts);
|
57
|
+
};
|
58
|
+
TimezoneUtil._getParts = function (oDate, sTargetTimezone) {
|
59
|
+
var oIntlDate = oIntlDateTimeFormatCache.get(sTargetTimezone);
|
60
|
+
var oParts = oIntlDate.formatToParts(new Date(oDate.getTime()));
|
61
|
+
var oDateParts = Object.create(null);
|
62
|
+
for (var sKey in oParts) {
|
63
|
+
var oPart = oParts[sKey];
|
64
|
+
if (oPart.type !== "literal") {
|
65
|
+
oDateParts[oPart.type] = oPart.value;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
return oDateParts;
|
69
|
+
};
|
70
|
+
TimezoneUtil._getDateFromParts = function (oParts) {
|
71
|
+
var oDate = new Date(0);
|
72
|
+
var iUTCYear = parseInt(oParts.year);
|
73
|
+
if (oParts.era === "B") {
|
74
|
+
iUTCYear = iUTCYear * -1 + 1;
|
75
|
+
}
|
76
|
+
oDate.setUTCFullYear(iUTCYear, parseInt(oParts.month) - 1, parseInt(oParts.day));
|
77
|
+
oDate.setUTCHours(parseInt(oParts.hour), parseInt(oParts.minute), parseInt(oParts.second), parseInt(oParts.fractionalSecond || 0));
|
78
|
+
return oDate;
|
79
|
+
};
|
80
|
+
TimezoneUtil.calculateOffset = function (oDate, sTimezoneSource) {
|
81
|
+
var oFirstGuess = this.convertToTimezone(oDate, sTimezoneSource);
|
82
|
+
var iInitialOffset = oDate.getTime() - oFirstGuess.getTime();
|
83
|
+
var oDateSource = new Date(oDate.getTime() + iInitialOffset);
|
84
|
+
var oDateTarget = this.convertToTimezone(oDateSource, sTimezoneSource);
|
85
|
+
return (oDateSource.getTime() - oDateTarget.getTime()) / 1000;
|
86
|
+
};
|
87
|
+
TimezoneUtil.getLocalTimezone = function () {
|
88
|
+
if (sLocalTimezone) {
|
89
|
+
return sLocalTimezone;
|
90
|
+
}
|
91
|
+
sLocalTimezone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
92
|
+
return sLocalTimezone;
|
93
|
+
};
|
94
|
+
export default TimezoneUtil;
|
package/package-scripts.js
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
const resolve = require("resolve");
|
2
|
-
const generateHash = resolve.sync("@ui5/webcomponents-tools/lib/hash/generate.js");
|
3
|
-
const hashIsUpToDate = resolve.sync("@ui5/webcomponents-tools/lib/hash/upToDate.js");
|
4
2
|
const copyUsedModules = resolve.sync("@ui5/webcomponents-tools/lib/copy-list/index.js");
|
5
3
|
const replaceGlobalCore = resolve.sync("@ui5/webcomponents-tools/lib/replace-global-core/index.js");
|
6
4
|
const esmAbsToRel = resolve.sync("@ui5/webcomponents-tools/lib/esm-abs-to-rel/index.js");
|
7
|
-
const UP_TO_DATE = `node "${hashIsUpToDate}" dist/ hash.txt && echo "Up to date."`;
|
8
5
|
|
9
6
|
const scripts = {
|
10
7
|
clean: "rimraf dist",
|
11
8
|
lint: "eslint . --config config/.eslintrc.js",
|
12
9
|
build: {
|
13
|
-
"default":
|
14
|
-
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",
|
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",
|
15
11
|
"replace-amd": "replace-in-file sap.ui.define define dist/**/*.js",
|
16
12
|
"replace-export-true": `replace-in-file ", /* bExport= */ true" "" dist/**/*.js`,
|
17
13
|
"replace-export-false": `replace-in-file ", /* bExport= */ false" "" dist/**/*.js`,
|
18
14
|
"amd-to-es6": "amdtoes6 --src=dist --replace --glob=**/*.js",
|
19
15
|
"replace-global-core-usage": `node "${replaceGlobalCore}" dist/`,
|
20
16
|
"esm-abs-to-rel": `node "${esmAbsToRel}" dist/`,
|
17
|
+
typescript: "tsc",
|
21
18
|
jsonImports: "node ./lib/generate-json-imports/cldr.js"
|
22
19
|
},
|
20
|
+
typescript: "tsc",
|
23
21
|
copy: {
|
24
22
|
"used-modules": `node "${copyUsedModules}" ./used-modules.txt dist/`,
|
25
23
|
cldr: `copy-and-watch "../../node_modules/@openui5/sap.ui.core/src/sap/ui/core/cldr/*.json" dist/generated/assets/cldr/`,
|
@@ -27,11 +25,11 @@ const scripts = {
|
|
27
25
|
src: `copy-and-watch "src/**/*.js" dist/`,
|
28
26
|
},
|
29
27
|
watch: {
|
30
|
-
default: 'nps watch.src',
|
28
|
+
default: 'concurrently "nps watch.src" "nps watch.typescript" ',
|
29
|
+
typescript: "tsc --watch",
|
31
30
|
src: `nps "copy.src --watch --skip-initial-copy"`,
|
32
31
|
},
|
33
32
|
start: "nps watch",
|
34
|
-
hash: `node ${generateHash} dist/ hash.txt`
|
35
33
|
};
|
36
34
|
|
37
35
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-localization",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-d4d43327a",
|
4
4
|
"description": "Localization for UI5 Web Components",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -24,16 +24,17 @@
|
|
24
24
|
"lint": "nps lint",
|
25
25
|
"start": "nps start",
|
26
26
|
"build": "nps build",
|
27
|
-
"hash": "nps hash",
|
28
27
|
"prepublishOnly": "npm run clean && npm run build"
|
29
28
|
},
|
30
29
|
"devDependencies": {
|
31
|
-
"@
|
32
|
-
"
|
30
|
+
"@openui5/sap.ui.core": "1.109.0",
|
31
|
+
"@ui5/webcomponents-tools": "0.0.0-d4d43327a",
|
32
|
+
"chromedriver": "109.0.0",
|
33
33
|
"mkdirp": "^1.0.4",
|
34
34
|
"resolve": "^1.20.0"
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@
|
37
|
+
"@types/openui5": "^1.109.0",
|
38
|
+
"@ui5/webcomponents-base": "0.0.0-d4d43327a"
|
38
39
|
}
|
39
40
|
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type DateFormatT from "sap/ui/core/format/DateFormat";
|
2
|
+
// @ts-ignore
|
3
|
+
import DateFormatNative from "./sap/ui/core/format/DateFormat.js";
|
4
|
+
|
5
|
+
const DateFormatWrapped = DateFormatNative as typeof DateFormatT;
|
6
|
+
class DateFormat extends DateFormatWrapped {}
|
7
|
+
|
8
|
+
export default DateFormat;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type LocaleDataOpenUI5T from "sap/ui/core/LocaleData";
|
2
|
+
// @ts-ignore
|
3
|
+
import LocaleDataNative from "./sap/ui/core/LocaleData.js";
|
4
|
+
|
5
|
+
const LocaleDataWrapped = LocaleDataNative as typeof LocaleDataOpenUI5T;
|
6
|
+
class LocaleData extends LocaleDataWrapped {}
|
7
|
+
|
8
|
+
export default LocaleData;
|
@@ -1,23 +1,26 @@
|
|
1
|
-
import
|
1
|
+
import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
|
2
|
+
import UniversalDate from "./UniversalDate.js";
|
2
3
|
|
3
4
|
class CalendarDate {
|
4
|
-
|
5
|
+
_oUDate!: Date | UniversalDate;
|
6
|
+
|
7
|
+
constructor(year?: number | CalendarDate, month?: number | string, date?: number, calendarType?: string) { // eslint-disable-line
|
5
8
|
let aArgs = arguments, // eslint-disable-line
|
6
|
-
oJSDate,
|
7
|
-
oNow,
|
8
|
-
sCalendarType;
|
9
|
+
oJSDate: Date,
|
10
|
+
oNow: Date,
|
11
|
+
sCalendarType!: CalendarType;
|
9
12
|
|
10
13
|
switch (aArgs.length) {
|
11
14
|
case 0: // defaults to the current date
|
12
15
|
oNow = new Date();
|
13
|
-
return this.constructor(oNow.getFullYear(), oNow.getMonth(), oNow.getDate());
|
16
|
+
return (this.constructor(oNow.getFullYear(), oNow.getMonth(), oNow.getDate()) as CalendarDate);
|
14
17
|
|
15
18
|
case 1: // CalendarDate
|
16
19
|
case 2: // CalendarDate, sCalendarType
|
17
20
|
if (!(aArgs[0] instanceof CalendarDate)) {
|
18
|
-
throw new Error("Invalid arguments: the first argument must be of type
|
21
|
+
throw new Error("Invalid arguments: the first argument must be of type CalendarDate.");
|
19
22
|
}
|
20
|
-
sCalendarType = aArgs[1] ? aArgs[1] : aArgs[0]._oUDate.sCalendarType;
|
23
|
+
sCalendarType = aArgs[1] ? aArgs[1] : (aArgs[0]._oUDate as UniversalDate).sCalendarType;
|
21
24
|
// Use source.valueOf() (returns the same point of time regardless calendar type) instead of
|
22
25
|
// source's getters to avoid non-gregorian Year, Month and Date may be used to construct a Gregorian date
|
23
26
|
oJSDate = new Date(aArgs[0].valueOf());
|
@@ -31,12 +34,12 @@ class CalendarDate {
|
|
31
34
|
|
32
35
|
case 3: // year, month, date
|
33
36
|
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
|
+
checkNumericLike(aArgs[0] as number, `Invalid year: ${aArgs[0] as number}`);
|
38
|
+
checkNumericLike(aArgs[1] as number, `Invalid month: ${aArgs[1] as number}`);
|
39
|
+
checkNumericLike(aArgs[2] as number, `Invalid date: ${aArgs[2] as number}`);
|
37
40
|
|
38
41
|
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.
|
42
|
+
oJSDate.setFullYear(aArgs[0] as number, aArgs[1] as number, aArgs[2] as number); // 2 digits year is not supported. If so, it is considered as full year as well.
|
40
43
|
|
41
44
|
if (aArgs[3]) {
|
42
45
|
sCalendarType = aArgs[3];
|
@@ -46,7 +49,7 @@ class CalendarDate {
|
|
46
49
|
|
47
50
|
default:
|
48
51
|
throw new Error(`${"Invalid arguments. Accepted arguments are: 1) oCalendarDate, (optional)calendarType"
|
49
|
-
+ "or 2) year, month, date, (optional) calendarType"}${aArgs}`);
|
52
|
+
+ "or 2) year, month, date, (optional) calendarType"}${aArgs as unknown as string}`);
|
50
53
|
}
|
51
54
|
}
|
52
55
|
|
@@ -54,7 +57,7 @@ class CalendarDate {
|
|
54
57
|
return this._oUDate.getUTCFullYear();
|
55
58
|
}
|
56
59
|
|
57
|
-
setYear(year) {
|
60
|
+
setYear(year: number) {
|
58
61
|
checkNumericLike(year, `Invalid year: ${year}`);
|
59
62
|
this._oUDate.setUTCFullYear(year);
|
60
63
|
return this;
|
@@ -79,7 +82,7 @@ class CalendarDate {
|
|
79
82
|
* Other value will result in adding or subtracting days according to the given value.
|
80
83
|
* @returns {sap.ui.unified.calendar.CalendarDate} <code>this</code> for method chaining.
|
81
84
|
*/
|
82
|
-
setMonth(month, date) {
|
85
|
+
setMonth(month: number, date?: number) {
|
83
86
|
checkNumericLike(month, `Invalid month: ${month}`);
|
84
87
|
if (date || date === 0) {
|
85
88
|
checkNumericLike(date, `Invalid date: ${date}`);
|
@@ -94,7 +97,7 @@ class CalendarDate {
|
|
94
97
|
return this._oUDate.getUTCDate();
|
95
98
|
}
|
96
99
|
|
97
|
-
setDate(date) {
|
100
|
+
setDate(date: number) {
|
98
101
|
checkNumericLike(date, `Invalid date: ${date}`);
|
99
102
|
this._oUDate.setUTCDate(date);
|
100
103
|
return this;
|
@@ -105,30 +108,30 @@ class CalendarDate {
|
|
105
108
|
}
|
106
109
|
|
107
110
|
getCalendarType() {
|
108
|
-
return this._oUDate.sCalendarType;
|
111
|
+
return (this._oUDate as UniversalDate).sCalendarType;
|
109
112
|
}
|
110
113
|
|
111
|
-
isBefore(oCalendarDate) {
|
114
|
+
isBefore(oCalendarDate: CalendarDate) {
|
112
115
|
checkCalendarDate(oCalendarDate);
|
113
116
|
return this.valueOf() < oCalendarDate.valueOf();
|
114
117
|
}
|
115
118
|
|
116
|
-
isAfter(oCalendarDate) {
|
119
|
+
isAfter(oCalendarDate: CalendarDate) {
|
117
120
|
checkCalendarDate(oCalendarDate);
|
118
121
|
return this.valueOf() > oCalendarDate.valueOf();
|
119
122
|
}
|
120
123
|
|
121
|
-
isSameOrBefore(oCalendarDate) {
|
124
|
+
isSameOrBefore(oCalendarDate: CalendarDate) {
|
122
125
|
checkCalendarDate(oCalendarDate);
|
123
126
|
return this.valueOf() <= oCalendarDate.valueOf();
|
124
127
|
}
|
125
128
|
|
126
|
-
isSameOrAfter(oCalendarDate) {
|
129
|
+
isSameOrAfter(oCalendarDate: CalendarDate) {
|
127
130
|
checkCalendarDate(oCalendarDate);
|
128
131
|
return this.valueOf() >= oCalendarDate.valueOf();
|
129
132
|
}
|
130
133
|
|
131
|
-
isSame(oCalendarDate) {
|
134
|
+
isSame(oCalendarDate: CalendarDate) {
|
132
135
|
checkCalendarDate(oCalendarDate);
|
133
136
|
return this.valueOf() === oCalendarDate.valueOf();
|
134
137
|
}
|
@@ -155,34 +158,40 @@ class CalendarDate {
|
|
155
158
|
}
|
156
159
|
|
157
160
|
toString() {
|
158
|
-
return `${this._oUDate.sCalendarType}: ${this.getYear()}/${this.getMonth() + 1}/${this.getDate()}`;
|
161
|
+
return `${(this._oUDate as UniversalDate).sCalendarType}: ${this.getYear()}/${this.getMonth() + 1}/${this.getDate()}`;
|
159
162
|
}
|
160
163
|
|
161
164
|
valueOf() {
|
162
165
|
return this._oUDate.getTime();
|
163
166
|
}
|
164
167
|
|
165
|
-
static fromLocalJSDate(oJSDate, sCalendarType) {
|
168
|
+
static fromLocalJSDate(oJSDate: Date, sCalendarType?: CalendarType) {
|
166
169
|
// Cross frame check for a date should be performed here otherwise setDateValue would fail in OPA tests
|
167
170
|
// because Date object in the test is different than the Date object in the application (due to the iframe).
|
168
171
|
// We can use jQuery.type or this method:
|
169
|
-
function isValidDate(date) {
|
170
|
-
return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date); // eslint-disable-line
|
172
|
+
function isValidDate(date: Date) {
|
173
|
+
return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date as unknown as number); // eslint-disable-line
|
171
174
|
}
|
172
175
|
if (!isValidDate(oJSDate)) {
|
173
|
-
throw new Error(`Date parameter must be a JavaScript Date object: [${oJSDate}].`);
|
176
|
+
throw new Error(`Date parameter must be a JavaScript Date object: [${oJSDate as unknown as string}].`);
|
174
177
|
}
|
175
178
|
return new CalendarDate(oJSDate.getFullYear(), oJSDate.getMonth(), oJSDate.getDate(), sCalendarType);
|
176
179
|
}
|
177
180
|
|
178
|
-
static fromTimestamp(iTimestamp, sCalendarType) {
|
181
|
+
static fromTimestamp(iTimestamp: number, sCalendarType?: CalendarType) {
|
179
182
|
const oCalDate = new CalendarDate(0, 0, 1);
|
180
|
-
|
183
|
+
let oUDate;
|
184
|
+
try {
|
185
|
+
oUDate = UniversalDate.getInstance(new Date(iTimestamp), sCalendarType);
|
186
|
+
} catch (e) {
|
187
|
+
oUDate = new Date(NaN); // UniversalDate.getInstance may now throw an Exception - keep the old behavior
|
188
|
+
}
|
189
|
+
oCalDate._oUDate = oUDate;
|
181
190
|
return oCalDate;
|
182
191
|
}
|
183
192
|
}
|
184
193
|
|
185
|
-
function createUniversalUTCDate(oDate, sCalendarType) {
|
194
|
+
function createUniversalUTCDate(oDate: Date, sCalendarType: CalendarType) {
|
186
195
|
if (sCalendarType) {
|
187
196
|
return UniversalDate.getInstance(createUTCDate(oDate), sCalendarType);
|
188
197
|
}
|
@@ -194,7 +203,7 @@ function createUniversalUTCDate(oDate, sCalendarType) {
|
|
194
203
|
* @param {Date} oDate JavaScript date object. Time related information is cut.
|
195
204
|
* @returns {Date} JavaScript date created from the date object, but this time considered as UTC date information.
|
196
205
|
*/
|
197
|
-
function createUTCDate(oDate) {
|
206
|
+
function createUTCDate(oDate: Date) {
|
198
207
|
const oUTCDate = new Date(Date.UTC(0, 0, 1));
|
199
208
|
|
200
209
|
oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
|
@@ -202,9 +211,9 @@ function createUTCDate(oDate) {
|
|
202
211
|
return oUTCDate;
|
203
212
|
}
|
204
213
|
|
205
|
-
function checkCalendarDate(oCalendarDate) {
|
214
|
+
function checkCalendarDate(oCalendarDate: CalendarDate) {
|
206
215
|
if (!(oCalendarDate instanceof CalendarDate)) {
|
207
|
-
throw new Error(`Invalid calendar date: [${oCalendarDate}]. Expected:
|
216
|
+
throw new Error(`Invalid calendar date: [${oCalendarDate as unknown as string}]. Expected: CalendarDate`);
|
208
217
|
}
|
209
218
|
}
|
210
219
|
|
@@ -214,7 +223,7 @@ function checkCalendarDate(oCalendarDate) {
|
|
214
223
|
* @param {string} message The message to be used if an error is to be thrown
|
215
224
|
* @throws will throw an error if the value is null or undefined or is not like a number
|
216
225
|
*/
|
217
|
-
function checkNumericLike(value, message) {
|
226
|
+
function checkNumericLike(value: any, message: string) {
|
218
227
|
if (value === undefined || value === Infinity || isNaN(value)) { // eslint-disable-line
|
219
228
|
throw message;
|
220
229
|
}
|
@@ -1,8 +1,9 @@
|
|
1
|
+
import CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
|
1
2
|
import CalendarDate from "./CalendarDate.js";
|
2
3
|
|
3
|
-
const cache = new Map();
|
4
|
+
const cache = new Map<string, CalendarDate>();
|
4
5
|
|
5
|
-
const getMinCalendarDate = primaryCalendarType => {
|
6
|
+
const getMinCalendarDate = (primaryCalendarType: CalendarType) => {
|
6
7
|
const key = `min ${primaryCalendarType}`;
|
7
8
|
|
8
9
|
if (!cache.has(key)) {
|
@@ -13,10 +14,10 @@ const getMinCalendarDate = primaryCalendarType => {
|
|
13
14
|
cache.set(key, minDate);
|
14
15
|
}
|
15
16
|
|
16
|
-
return cache.get(key)
|
17
|
+
return cache.get(key)!;
|
17
18
|
};
|
18
19
|
|
19
|
-
const getMaxCalendarDate = primaryCalendarType => {
|
20
|
+
const getMaxCalendarDate = (primaryCalendarType: CalendarType) => {
|
20
21
|
const key = `max ${primaryCalendarType}`;
|
21
22
|
|
22
23
|
if (!cache.has(key)) {
|
@@ -30,7 +31,7 @@ const getMaxCalendarDate = primaryCalendarType => {
|
|
30
31
|
cache.set(key, maxDate);
|
31
32
|
}
|
32
33
|
|
33
|
-
return cache.get(key)
|
34
|
+
return cache.get(key)!;
|
34
35
|
};
|
35
36
|
|
36
37
|
export {
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
|
2
|
+
// @ts-ignore
|
3
|
+
import UniversalDateNative from "../sap/ui/core/date/UniversalDate.js";
|
4
|
+
|
5
|
+
type UniversalDate = {
|
6
|
+
new (time: number): UniversalDate;
|
7
|
+
oDate: Date,
|
8
|
+
sCalendarType: string,
|
9
|
+
getInstance: (oDate: Date, sCalendarType?: CalendarType) => UniversalDate,
|
10
|
+
getDate: () => number,
|
11
|
+
getMonth: () => number,
|
12
|
+
getFullYear: () => number,
|
13
|
+
getYear: () => number,
|
14
|
+
getDay: () => number,
|
15
|
+
getHours: () => number,
|
16
|
+
getMinutes: () => number,
|
17
|
+
getSeconds: () => number,
|
18
|
+
getMilliseconds: () => number,
|
19
|
+
getUTCDate: () => number,
|
20
|
+
getUTCMonth: () => number,
|
21
|
+
getUTCFullYear: () => number,
|
22
|
+
getUTCDay: () => number,
|
23
|
+
getUTCHours: () => number,
|
24
|
+
getUTCMinutes: () => number,
|
25
|
+
getUTCSeconds: () => number,
|
26
|
+
getUTCMilliseconds: () => number,
|
27
|
+
getTime: () => number,
|
28
|
+
valueOf: () => number,
|
29
|
+
getTimezoneOffset: () => number,
|
30
|
+
toString: () => string,
|
31
|
+
toDateString: () => string,
|
32
|
+
setDate: (dayValue: number) => number,
|
33
|
+
setFullYear: (yearValue: number, monthValue?: number, dateValue?: number) => number,
|
34
|
+
setYear: (yearValue: number) => number,
|
35
|
+
setMonth: (monthValue: number, dayValue?: number) => number,
|
36
|
+
setHours: (hoursValue: number, minutesValue?: number, secondsValue?: number, msValue?: number) => number,
|
37
|
+
setMinutes: (minutesValue: number, secondsValue?: number, msValue?: number) => number,
|
38
|
+
setSeconds: (secondsValue: number, msValue?: number) => number,
|
39
|
+
setMilliseconds: (setMilliseconds: number) => number,
|
40
|
+
setUTCDate:(dayValue: number) => number,
|
41
|
+
setUTCFullYear: (yearValue: number, monthValue?: number, dayValue?: number) => number,
|
42
|
+
setUTCMonth: (monthValue: number, dayValue?: number) => number,
|
43
|
+
setUTCHours: (hoursValue: number, minutesValue?: number, secondsValue?: number, msValue?: number) => number,
|
44
|
+
setUTCMinutes: (minutesValue: number, secondsValue?: number, msValue?: number) => number,
|
45
|
+
setUTCSeconds: (secondsValue: number, msValue?: number) => number,
|
46
|
+
setUTCMilliseconds: (setMilliseconds: number) => number,
|
47
|
+
}
|
48
|
+
|
49
|
+
const UniversalDate: UniversalDate = UniversalDateNative;
|
50
|
+
|
51
|
+
export default UniversalDate;
|
@@ -1,9 +1,11 @@
|
|
1
|
-
import
|
1
|
+
import type Locale from "@ui5/webcomponents-base/dist/locale/Locale.js";
|
2
|
+
import UniversalDate from "./UniversalDate.js";
|
3
|
+
import type LocaleData from "../LocaleData.js";
|
2
4
|
|
3
|
-
const calculateWeekNumber = (confFirstDayOfWeek, oDate, iYear, oLocale, oLocaleData) => {
|
5
|
+
const calculateWeekNumber = (confFirstDayOfWeek: number | undefined, oDate: Date, iYear: number, oLocale: Locale, oLocaleData: LocaleData) => {
|
4
6
|
let iWeekNum = 0;
|
5
7
|
let iWeekDay = 0;
|
6
|
-
const iFirstDayOfWeek = Number.isInteger(confFirstDayOfWeek) ? confFirstDayOfWeek : oLocaleData.getFirstDayOfWeek();
|
8
|
+
const iFirstDayOfWeek = Number.isInteger(confFirstDayOfWeek) ? confFirstDayOfWeek! : oLocaleData.getFirstDayOfWeek();
|
7
9
|
|
8
10
|
// search Locale for containing "en-US", since sometimes
|
9
11
|
// when any user settings have been defined, subtag "sapufmt" is added to the locale name
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
|
2
|
+
import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
|
3
|
+
import getCachedLocaleDataInstance from "../getCachedLocaleDataInstance.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Convert month number to month name (text).
|
7
|
+
* If the numbers of the two months are the same you will get the name of the month,
|
8
|
+
* otherwise you will get the two names separated by a dash
|
9
|
+
*
|
10
|
+
* @param firstMonth CalendarDate Month
|
11
|
+
* @param lastMonth CalendarDate Month
|
12
|
+
* @param calendarType calendar type
|
13
|
+
* @returns {String}
|
14
|
+
*/
|
15
|
+
const convertMonthNumbersToMonthNames = (firstMonth: number, lastMonth: number, calendarType?: CalendarType) => {
|
16
|
+
const localeData = getCachedLocaleDataInstance(getLocale());
|
17
|
+
const pattern = localeData.getIntervalPattern("");
|
18
|
+
const secondaryMonthsNames = localeData.getMonthsStandAlone("abbreviated", calendarType) as Array<string>;
|
19
|
+
const secondaryMonthsNamesWide = localeData.getMonthsStandAlone("wide", calendarType) as Array<string>;
|
20
|
+
|
21
|
+
if (firstMonth === lastMonth) {
|
22
|
+
return {
|
23
|
+
text: localeData.getMonths("abbreviated", calendarType)[firstMonth],
|
24
|
+
textInfo: localeData.getMonths("wide", calendarType)[firstMonth],
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
28
|
+
return {
|
29
|
+
text: pattern.replace(/\{0\}/, secondaryMonthsNames[firstMonth]).replace(/\{1\}/, secondaryMonthsNames[lastMonth]),
|
30
|
+
textInfo: pattern.replace(/\{0\}/, secondaryMonthsNamesWide[firstMonth]).replace(/\{1\}/, secondaryMonthsNamesWide[lastMonth]),
|
31
|
+
};
|
32
|
+
};
|
33
|
+
|
34
|
+
export default convertMonthNumbersToMonthNames;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import CalendarDate from "./CalendarDate.js";
|
2
|
+
|
3
|
+
const getDaysInMonth = (date: CalendarDate) => {
|
4
|
+
const tempCalendarDate = new CalendarDate(date);
|
5
|
+
tempCalendarDate.setDate(1);
|
6
|
+
tempCalendarDate.setMonth(tempCalendarDate.getMonth() + 1);
|
7
|
+
tempCalendarDate.setDate(0);
|
8
|
+
return tempCalendarDate.getDate();
|
9
|
+
};
|
10
|
+
|
11
|
+
export default getDaysInMonth;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/**
|
2
2
|
* Returns a timestamp with only the year, month and day (with zero hours, minutes and seconds) and without 000 for milliseconds
|
3
|
-
* @param millisecondsUTC
|
4
|
-
* @returns {number}
|
3
|
+
* @param { number } millisecondsUTC
|
4
|
+
* @returns { number }
|
5
5
|
*/
|
6
|
-
const getRoundedTimestamp = millisecondsUTC => {
|
6
|
+
const getRoundedTimestamp = (millisecondsUTC: number) => {
|
7
7
|
if (!millisecondsUTC) {
|
8
8
|
millisecondsUTC = new Date().getTime();
|
9
9
|
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
|
2
|
+
import CalendarDate from "./CalendarDate.js";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Returns a UTC timestamp representing today
|
6
|
+
* @public
|
7
|
+
*/
|
8
|
+
const getTodayUTCTimestamp = (primaryCalendarType: CalendarType) => CalendarDate.fromLocalJSDate(new Date(), primaryCalendarType).valueOf() / 1000;
|
9
|
+
|
10
|
+
export default getTodayUTCTimestamp;
|
@@ -10,7 +10,7 @@ import CalendarDate from "./CalendarDate.js";
|
|
10
10
|
* @param minDate minimum date to enforce
|
11
11
|
* @param maxDate maximum date to enforce
|
12
12
|
*/
|
13
|
-
const modifyDateBy = (date, amount, unit, minDate
|
13
|
+
const modifyDateBy = (date: CalendarDate, amount: number, unit: string, minDate?: CalendarDate, maxDate?: CalendarDate) => {
|
14
14
|
const newDate = new CalendarDate(date);
|
15
15
|
if (unit === "day") {
|
16
16
|
newDate.setDate(date.getDate() + amount);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
|
2
|
+
import CalendarDate from "./CalendarDate.js";
|
3
|
+
import getDaysInMonth from "./getDaysInMonth.js";
|
4
|
+
|
5
|
+
const transformDateToSecondaryType = (primaryCalendarType: CalendarType | undefined, secondaryCalendarType: CalendarType| undefined, timeStamp: number, hasYearPicker?: boolean) => {
|
6
|
+
let firstDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);
|
7
|
+
let lastDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);
|
8
|
+
firstDate.setDate(1);
|
9
|
+
|
10
|
+
if (hasYearPicker) {
|
11
|
+
firstDate.setMonth(0);
|
12
|
+
lastDate.setMonth(11);
|
13
|
+
}
|
14
|
+
|
15
|
+
lastDate.setDate(getDaysInMonth(lastDate));
|
16
|
+
firstDate = new CalendarDate(firstDate, secondaryCalendarType);
|
17
|
+
lastDate = new CalendarDate(lastDate, secondaryCalendarType);
|
18
|
+
return { firstDate, lastDate };
|
19
|
+
};
|
20
|
+
|
21
|
+
export default transformDateToSecondaryType;
|
@@ -0,0 +1 @@
|
|
1
|
+
import "../../sap/ui/core/date/Buddhist.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
import "../../sap/ui/core/date/Gregorian.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
import "../../sap/ui/core/date/Islamic.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
import "../../sap/ui/core/date/Japanese.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
import "../../sap/ui/core/date/Persian.js";
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type Locale from "@ui5/webcomponents-base/dist/locale/Locale.js";
|
2
|
+
import type LocaleT from "sap/ui/core/Locale";
|
3
|
+
import LocaleData from "./LocaleData.js";
|
4
|
+
|
5
|
+
const cache = new Map<Locale, LocaleData>();
|
6
|
+
|
7
|
+
const getCachedLocaleDataInstance = (locale: Locale) => {
|
8
|
+
if (!cache.has(locale)) {
|
9
|
+
cache.set(locale, new LocaleData(locale as unknown as LocaleT));
|
10
|
+
}
|
11
|
+
|
12
|
+
return cache.get(locale)!;
|
13
|
+
};
|
14
|
+
|
15
|
+
export default getCachedLocaleDataInstance;
|