@ui5/webcomponents-localization 0.0.0-0fcda382e → 0.0.0-10f3c0dc7
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 +2 -0
- package/.npsrc.json +3 -0
- package/CHANGELOG.md +2427 -0
- package/LICENSE.txt +201 -0
- package/README.md +38 -10
- package/dist/.tsbuildinfo +1 -0
- package/dist/Assets-fetch.d.ts +1 -0
- package/dist/Assets-fetch.js +3 -0
- package/dist/Assets-fetch.js.map +1 -0
- package/dist/Assets-node.d.ts +11 -0
- package/dist/Assets-node.js +12 -0
- package/dist/Assets-node.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/CalendarUtils.d.ts +3 -0
- package/dist/CalendarUtils.js +6 -0
- package/dist/CalendarUtils.js.map +1 -0
- package/dist/DateFormat.d.ts +28 -0
- package/dist/DateFormat.js +22 -2
- package/dist/DateFormat.js.map +1 -0
- package/dist/Locale.d.ts +5 -0
- package/dist/Locale.js +7 -0
- package/dist/Locale.js.map +1 -0
- package/dist/LocaleData.d.ts +5 -0
- package/dist/LocaleData.js +6 -2
- package/dist/LocaleData.js.map +1 -0
- package/dist/NumberFormat.d.ts +5 -0
- package/dist/NumberFormat.js +7 -0
- package/dist/NumberFormat.js.map +1 -0
- package/dist/dates/CalendarDate.d.ts +42 -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 +5 -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/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 +14 -0
- package/dist/dates/modifyDateBy.js +55 -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/Unicode-Data-Files-LICENSE.txt +39 -0
- package/dist/generated/assets/cldr/ar.json +2179 -728
- package/dist/generated/assets/cldr/ar_EG.json +2179 -728
- package/dist/generated/assets/cldr/ar_SA.json +2275 -825
- package/dist/generated/assets/cldr/bg.json +1924 -798
- package/dist/generated/assets/cldr/ca.json +2027 -816
- package/dist/generated/assets/cldr/cnr.json +6476 -0
- package/dist/generated/assets/cldr/cs.json +1865 -842
- package/dist/generated/assets/cldr/cy.json +6566 -0
- package/dist/generated/assets/cldr/da.json +1844 -682
- package/dist/generated/assets/cldr/de.json +1806 -546
- package/dist/generated/assets/cldr/de_AT.json +1797 -537
- package/dist/generated/assets/cldr/de_CH.json +1879 -611
- package/dist/generated/assets/cldr/el.json +1497 -383
- package/dist/generated/assets/cldr/el_CY.json +1497 -383
- package/dist/generated/assets/cldr/en.json +1990 -563
- package/dist/generated/assets/cldr/en_AU.json +2339 -763
- package/dist/generated/assets/cldr/en_GB.json +2170 -621
- package/dist/generated/assets/cldr/en_HK.json +2076 -628
- package/dist/generated/assets/cldr/en_IE.json +2038 -593
- package/dist/generated/assets/cldr/en_IN.json +2336 -704
- package/dist/generated/assets/cldr/en_NZ.json +2056 -611
- package/dist/generated/assets/cldr/en_PG.json +2049 -604
- package/dist/generated/assets/cldr/en_SG.json +2041 -593
- package/dist/generated/assets/cldr/en_ZA.json +2046 -599
- package/dist/generated/assets/cldr/es.json +2197 -881
- package/dist/generated/assets/cldr/es_AR.json +2167 -819
- package/dist/generated/assets/cldr/es_BO.json +2210 -863
- package/dist/generated/assets/cldr/es_CL.json +2087 -848
- package/dist/generated/assets/cldr/es_CO.json +1947 -707
- package/dist/generated/assets/cldr/es_MX.json +2446 -1091
- package/dist/generated/assets/cldr/es_PE.json +1912 -773
- package/dist/generated/assets/cldr/es_UY.json +1926 -795
- package/dist/generated/assets/cldr/es_VE.json +1920 -789
- package/dist/generated/assets/cldr/et.json +1761 -544
- package/dist/generated/assets/cldr/fa.json +1872 -566
- package/dist/generated/assets/cldr/fi.json +1959 -526
- package/dist/generated/assets/cldr/fr.json +1711 -460
- package/dist/generated/assets/cldr/fr_BE.json +1710 -459
- package/dist/generated/assets/cldr/fr_CA.json +2087 -814
- package/dist/generated/assets/cldr/fr_CH.json +1669 -418
- package/dist/generated/assets/cldr/fr_LU.json +1711 -460
- package/dist/generated/assets/cldr/he.json +2018 -1033
- package/dist/generated/assets/cldr/hi.json +1619 -348
- package/dist/generated/assets/cldr/hr.json +1855 -569
- package/dist/generated/assets/cldr/hu.json +1764 -551
- package/dist/generated/assets/cldr/id.json +1924 -601
- package/dist/generated/assets/cldr/it.json +1821 -666
- package/dist/generated/assets/cldr/it_CH.json +1827 -672
- package/dist/generated/assets/cldr/ja.json +1426 -109
- package/dist/generated/assets/cldr/kk.json +2251 -737
- package/dist/generated/assets/cldr/ko.json +1484 -196
- package/dist/generated/assets/cldr/lt.json +1714 -734
- package/dist/generated/assets/cldr/lv.json +1686 -682
- package/dist/generated/assets/cldr/mk.json +6177 -0
- package/dist/generated/assets/cldr/ms.json +1903 -595
- package/dist/generated/assets/cldr/nb.json +1548 -369
- package/dist/generated/assets/cldr/nl.json +1935 -511
- package/dist/generated/assets/cldr/nl_BE.json +1955 -531
- package/dist/generated/assets/cldr/pl.json +1873 -586
- package/dist/generated/assets/cldr/pt.json +2184 -753
- package/dist/generated/assets/cldr/pt_PT.json +2149 -778
- package/dist/generated/assets/cldr/ro.json +1847 -765
- package/dist/generated/assets/cldr/ru.json +2082 -755
- package/dist/generated/assets/cldr/ru_UA.json +2076 -749
- package/dist/generated/assets/cldr/sk.json +1860 -972
- package/dist/generated/assets/cldr/sl.json +1861 -920
- package/dist/generated/assets/cldr/sr.json +1829 -767
- package/dist/generated/assets/cldr/sr_Latn.json +6173 -0
- package/dist/generated/assets/cldr/sv.json +1789 -587
- package/dist/generated/assets/cldr/th.json +1704 -373
- package/dist/generated/assets/cldr/tr.json +1855 -587
- package/dist/generated/assets/cldr/uk.json +2166 -711
- package/dist/generated/assets/cldr/vi.json +2054 -709
- package/dist/generated/assets/cldr/zh_CN.json +1736 -397
- package/dist/generated/assets/cldr/zh_HK.json +1713 -374
- package/dist/generated/assets/cldr/zh_SG.json +1723 -384
- package/dist/generated/assets/cldr/zh_TW.json +1678 -371
- package/dist/generated/json-imports/LocaleData-fetch.d.ts +1 -0
- package/dist/generated/json-imports/LocaleData-fetch.js +93 -0
- package/dist/generated/json-imports/LocaleData-fetch.js.map +1 -0
- package/dist/generated/json-imports/LocaleData-node.d.ts +1 -0
- package/dist/generated/json-imports/LocaleData-node.js +93 -0
- package/dist/generated/json-imports/LocaleData-node.js.map +1 -0
- package/dist/generated/json-imports/LocaleData.d.ts +1 -0
- package/dist/generated/json-imports/LocaleData.js +92 -95
- package/dist/generated/json-imports/LocaleData.js.map +1 -0
- package/dist/getCachedLocaleDataInstance.d.ts +4 -0
- package/dist/getCachedLocaleDataInstance.js +12 -0
- package/dist/getCachedLocaleDataInstance.js.map +1 -0
- package/dist/locale/getLocaleData.d.ts +11 -0
- package/dist/locale/getLocaleData.js +15 -17
- package/dist/locale/getLocaleData.js.map +1 -0
- package/dist/sap/base/Event.js +59 -0
- package/dist/sap/base/Eventing.js +147 -0
- package/dist/sap/base/Log.js +2 -248
- package/dist/sap/base/assert.js +31 -9
- package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
- package/dist/sap/base/config.js +17 -0
- package/dist/sap/base/future.js +12 -0
- package/dist/sap/base/i18n/Formatting.d.ts +13 -0
- package/dist/sap/base/i18n/Formatting.js +18 -0
- package/dist/sap/base/i18n/Formatting.js.map +1 -0
- package/dist/sap/base/i18n/LanguageTag.js +179 -0
- package/dist/sap/base/i18n/Localization.d.ts +7 -0
- package/dist/sap/base/i18n/Localization.js +17 -0
- package/dist/sap/base/i18n/Localization.js.map +1 -0
- package/dist/sap/base/i18n/ResourceBundle.js +20 -0
- package/dist/sap/base/i18n/date/CalendarType.js +44 -0
- package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +106 -0
- package/dist/sap/base/i18n/date/TimezoneUtils.js +471 -0
- package/dist/sap/base/i18n/date/_EnumHelper.js +37 -0
- package/dist/sap/base/strings/camelize.js +30 -0
- package/dist/sap/base/strings/formatMessage.js +93 -15
- 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/ObjectPath.d.ts +4 -0
- package/dist/sap/base/util/ObjectPath.js +4 -33
- package/dist/sap/base/util/ObjectPath.js.map +1 -0
- package/dist/sap/base/util/Properties.js +12 -0
- package/dist/sap/base/util/Version.js +163 -0
- package/dist/sap/base/util/_merge.js +83 -26
- package/dist/sap/base/util/array/uniqueSort.js +37 -15
- package/dist/sap/base/util/deepClone.js +102 -0
- package/dist/sap/base/util/deepEqual.js +75 -55
- package/dist/sap/base/util/deepExtend.js +60 -0
- package/dist/sap/base/util/extend.js +58 -7
- package/dist/sap/base/util/fetch.js +8 -0
- package/dist/sap/base/util/isEmptyObject.js +34 -0
- package/dist/sap/base/util/isPlainObject.js +35 -1
- package/dist/sap/base/util/merge.js +57 -0
- package/dist/sap/base/util/mixedFetch.js +3 -0
- package/dist/sap/base/util/now.js +22 -7
- package/dist/sap/base/util/resolveReference.js +3 -0
- package/dist/sap/base/util/uid.js +27 -0
- package/dist/sap/ui/Device.js +25 -3
- package/dist/sap/ui/Global.js +1 -0
- package/dist/sap/ui/VersionInfo.js +14 -0
- package/dist/sap/ui/base/DataType.js +708 -0
- package/dist/sap/ui/base/DesignTime.js +11 -0
- package/dist/sap/ui/base/EventProvider.js +21 -0
- package/dist/sap/ui/base/Interface.js +50 -6
- package/dist/sap/ui/base/Metadata.js +470 -173
- package/dist/sap/ui/base/Object.js +287 -27
- package/dist/sap/ui/base/OwnStatics.js +6 -0
- package/dist/sap/ui/base/SyncPromise.js +98 -0
- package/dist/sap/ui/core/AnimationMode.js +42 -0
- package/dist/sap/ui/core/CalendarType.js +24 -8
- package/dist/sap/ui/core/Configuration.d.ts +17 -0
- package/dist/sap/ui/core/Configuration.js +23 -0
- package/dist/sap/ui/core/Configuration.js.map +1 -0
- package/dist/sap/ui/core/ControlBehavior.js +11 -0
- package/dist/sap/ui/core/Core.d.ts +25 -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 +9 -0
- package/dist/sap/ui/core/FormatSettings.js +12 -0
- package/dist/sap/ui/core/FormatSettings.js.map +1 -0
- package/dist/sap/ui/core/Lib.js +41 -0
- package/dist/sap/ui/core/Locale.js +190 -116
- package/dist/sap/ui/core/LocaleData.js +2837 -2683
- package/dist/sap/ui/core/Supportability.js +5 -0
- package/dist/sap/ui/core/Theming.js +39 -0
- package/dist/sap/ui/core/_UrlResolver.js +11 -0
- package/dist/sap/ui/core/date/Buddhist.js +162 -93
- package/dist/sap/ui/core/date/CalendarUtils.js +67 -0
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
- package/dist/sap/ui/core/date/Gregorian.js +25 -10
- package/dist/sap/ui/core/date/Islamic.js +298 -185
- package/dist/sap/ui/core/date/Japanese.js +212 -117
- package/dist/sap/ui/core/date/Persian.js +324 -195
- package/dist/sap/ui/core/date/UI5Date.js +1039 -0
- package/dist/sap/ui/core/date/UniversalDate.js +1241 -217
- package/dist/sap/ui/core/date/_Calendars.js +10 -1
- package/dist/sap/ui/core/format/DateFormat.js +3160 -1781
- package/dist/sap/ui/core/format/FormatUtils.js +30 -0
- package/dist/sap/ui/core/format/NumberFormat.js +3164 -0
- package/dist/sap/ui/core/format/TimezoneUtil.js +93 -0
- package/dist/sap/ui/core/getCompatibilityVersion.js +7 -0
- package/dist/sap/ui/core/theming/ThemeHelper.js +14 -0
- package/dist/sap/ui/security/Security.js +12 -0
- package/dist/sap/ui/util/XMLHelper.js +11 -0
- package/dist/sap/ui/util/_URL.js +1 -0
- package/dist/ui5loader-autoconfig.js +1 -0
- package/package-scripts.cjs +35 -0
- package/package.json +27 -21
- package/tsconfig.json +24 -0
- package/used-modules.txt +33 -1
- package/dist/dates/calculateWeekNumber.js +0 -51
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"Assets-fetch.js","sourceRoot":"","sources":["../src/Assets-fetch.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,8CAA8C,CAAC","sourcesContent":["// Currently the base package provides CLDR assets only\nimport \"./generated/json-imports/LocaleData-fetch.js\";\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Assets-node` entry point is used to import CLDR assets.
|
|
3
|
+
*
|
|
4
|
+
* It serves as an alternative to the `Assets` and `Assets-fetch` modules and supports
|
|
5
|
+
* the `with: { type: 'json' }` import attribute for loading JSON files.
|
|
6
|
+
* This import attribute is required in some environments, such as Node.js with server-side rendering (SSR).
|
|
7
|
+
*
|
|
8
|
+
* Example usage:
|
|
9
|
+
* await import("../assets/i18n/messagebundle_bg.json", { with: { type: 'json' } })
|
|
10
|
+
*/
|
|
11
|
+
import "./generated/json-imports/LocaleData-node.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Assets-node` entry point is used to import CLDR assets.
|
|
3
|
+
*
|
|
4
|
+
* It serves as an alternative to the `Assets` and `Assets-fetch` modules and supports
|
|
5
|
+
* the `with: { type: 'json' }` import attribute for loading JSON files.
|
|
6
|
+
* This import attribute is required in some environments, such as Node.js with server-side rendering (SSR).
|
|
7
|
+
*
|
|
8
|
+
* Example usage:
|
|
9
|
+
* await import("../assets/i18n/messagebundle_bg.json", { with: { type: 'json' } })
|
|
10
|
+
*/
|
|
11
|
+
import "./generated/json-imports/LocaleData-node.js";
|
|
12
|
+
//# sourceMappingURL=Assets-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assets-node.js","sourceRoot":"","sources":["../src/Assets-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,6CAA6C,CAAC","sourcesContent":["/**\n * The `Assets-node` entry point is used to import CLDR assets.\n *\n * It serves as an alternative to the `Assets` and `Assets-fetch` modules and supports\n * the `with: { type: 'json' }` import attribute for loading JSON files.\n * This import attribute is required in some environments, such as Node.js with server-side rendering (SSR).\n *\n * Example usage:\n * await import(\"../assets/i18n/messagebundle_bg.json\", { with: { type: 'json' } })\n */\n\nimport \"./generated/json-imports/LocaleData-node.js\";\n"]}
|
package/dist/Assets.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./generated/json-imports/LocaleData.js";
|
package/dist/Assets.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assets.js","sourceRoot":"","sources":["../src/Assets.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,wCAAwC,CAAC","sourcesContent":["// Currently the base package provides CLDR assets only\nimport \"./generated/json-imports/LocaleData.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalendarUtils.js","sourceRoot":"","sources":["../src/CalendarUtils.ts"],"names":[],"mappings":"AACA,aAAa;AACb,OAAO,mBAAmB,MAAM,qCAAqC,CAAC;AAEtE,MAAM,oBAAoB,GAAG,mBAAoD,CAAC;AAClF,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAE3C,eAAe,aAAa,CAAC","sourcesContent":["import type CaledndarUtilsOpenui5T from \"sap/ui/core/date/CalendarUtils\";\n// @ts-ignore\nimport CalendarUtilsNative from \"./sap/ui/core/date/CalendarUtils.js\";\n\nconst CalendarUtilsWrapped = CalendarUtilsNative as typeof CaledndarUtilsOpenui5T;\nconst CalendarUtils = CalendarUtilsWrapped;\n\nexport default CalendarUtils;\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type DateFormatT from "sap/ui/core/format/DateFormat";
|
|
2
|
+
import LocaleWrapped from "./Locale.js";
|
|
3
|
+
import type CalendarWeekNumbering from "sap/base/i18n/date/CalendarWeekNumbering";
|
|
4
|
+
import type CalendarType from "sap/base/i18n/date/CalendarType";
|
|
5
|
+
type DateFormatOptions = {
|
|
6
|
+
calendarWeekNumbering?: CalendarWeekNumbering | keyof typeof CalendarWeekNumbering;
|
|
7
|
+
firstDayOfWeek?: int;
|
|
8
|
+
minimalDaysInFirstWeek?: int;
|
|
9
|
+
format?: string;
|
|
10
|
+
pattern?: string;
|
|
11
|
+
style?: string;
|
|
12
|
+
strictParsing?: boolean;
|
|
13
|
+
relative?: boolean;
|
|
14
|
+
relativeRange?: int[];
|
|
15
|
+
relativeScale?: string;
|
|
16
|
+
relativeStyle?: string;
|
|
17
|
+
interval?: boolean;
|
|
18
|
+
intervalDelimiter?: string;
|
|
19
|
+
singleIntervalValue?: boolean;
|
|
20
|
+
UTC?: boolean;
|
|
21
|
+
calendarType?: CalendarType | keyof typeof CalendarType;
|
|
22
|
+
};
|
|
23
|
+
declare const DateFormatWrapped: typeof DateFormatT;
|
|
24
|
+
declare class DateFormat extends DateFormatWrapped {
|
|
25
|
+
static getDateInstance(oFormatOptions?: DateFormatOptions, oLocale?: LocaleWrapped): DateFormat;
|
|
26
|
+
static getDateInstance(oLocale?: LocaleWrapped): DateFormat;
|
|
27
|
+
}
|
|
28
|
+
export default DateFormat;
|
package/dist/DateFormat.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import DateFormatNative from "./sap/ui/core/format/DateFormat.js";
|
|
3
|
+
import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
|
|
4
|
+
import LocaleWrapped from "./Locale.js";
|
|
5
|
+
const DateFormatWrapped = DateFormatNative;
|
|
6
|
+
const _dateFormatCache = new Map();
|
|
7
|
+
class DateFormat extends DateFormatWrapped {
|
|
8
|
+
static getDateInstance(oFormatOptionsOrLocale, oLocale) {
|
|
9
|
+
const locale = oLocale ?? new LocaleWrapped(getLocale().toString());
|
|
10
|
+
if (oFormatOptionsOrLocale instanceof LocaleWrapped) {
|
|
11
|
+
return DateFormatWrapped.getDateInstance(undefined, oFormatOptionsOrLocale);
|
|
12
|
+
}
|
|
13
|
+
const cacheKey = `${JSON.stringify(oFormatOptionsOrLocale ?? {})}__${String(locale)}`;
|
|
14
|
+
let instance = _dateFormatCache.get(cacheKey);
|
|
15
|
+
if (!instance) {
|
|
16
|
+
instance = DateFormatWrapped.getDateInstance(oFormatOptionsOrLocale, locale);
|
|
17
|
+
_dateFormatCache.set(cacheKey, instance);
|
|
18
|
+
}
|
|
19
|
+
return instance;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
3
22
|
export default DateFormat;
|
|
23
|
+
//# sourceMappingURL=DateFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateFormat.js","sourceRoot":"","sources":["../src/DateFormat.ts"],"names":[],"mappings":"AACA,aAAa;AACb,OAAO,gBAAgB,MAAM,oCAAoC,CAAC;AAClE,OAAO,SAAS,MAAM,kDAAkD,CAAC;AACzE,OAAO,aAAa,MAAM,aAAa,CAAC;AAuBxC,MAAM,iBAAiB,GAAG,gBAAsC,CAAC;AAEjE,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAsB,CAAC;AAEvD,MAAM,UAAW,SAAQ,iBAAiB;IAGzC,MAAM,CAAC,eAAe,CAAC,sBAA0D,EAAE,OAAuB;QACzG,MAAM,MAAM,GAAG,OAAO,IAAI,IAAI,aAAa,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEpE,IAAI,sBAAsB,YAAY,aAAa,EAAE,CAAC;YACrD,OAAO,iBAAiB,CAAC,eAAe,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,sBAAsB,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACtF,IAAI,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,QAAQ,GAAG,iBAAiB,CAAC,eAAe,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;YAC7E,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AAED,eAAe,UAAU,CAAC","sourcesContent":["import type DateFormatT from \"sap/ui/core/format/DateFormat\";\n// @ts-ignore\nimport DateFormatNative from \"./sap/ui/core/format/DateFormat.js\";\nimport getLocale from \"@ui5/webcomponents-base/dist/locale/getLocale.js\";\nimport LocaleWrapped from \"./Locale.js\";\nimport type CalendarWeekNumbering from \"sap/base/i18n/date/CalendarWeekNumbering\";\nimport type CalendarType from \"sap/base/i18n/date/CalendarType\";\n\ntype DateFormatOptions = {\n\tcalendarWeekNumbering?: CalendarWeekNumbering | keyof typeof CalendarWeekNumbering;\n\tfirstDayOfWeek?: int;\n\tminimalDaysInFirstWeek?: int;\n\tformat?: string;\n\tpattern?: string;\n\tstyle?: string;\n\tstrictParsing?: boolean;\n\trelative?: boolean;\n\trelativeRange?: int[];\n\trelativeScale?: string;\n\trelativeStyle?: string;\n\tinterval?: boolean;\n\tintervalDelimiter?: string;\n\tsingleIntervalValue?: boolean;\n\tUTC?: boolean;\n\tcalendarType?: CalendarType | keyof typeof CalendarType;\n};\n\nconst DateFormatWrapped = DateFormatNative as typeof DateFormatT;\n\nconst _dateFormatCache = new Map<string, DateFormat>();\n\nclass DateFormat extends DateFormatWrapped {\n\tstatic getDateInstance(oFormatOptions?: DateFormatOptions, oLocale?: LocaleWrapped): DateFormat;\n\tstatic getDateInstance(oLocale?: LocaleWrapped): DateFormat;\n\tstatic getDateInstance(oFormatOptionsOrLocale?: DateFormatOptions | LocaleWrapped, oLocale?: LocaleWrapped): DateFormat {\n\t\tconst locale = oLocale ?? new LocaleWrapped(getLocale().toString());\n\n\t\tif (oFormatOptionsOrLocale instanceof LocaleWrapped) {\n\t\t\treturn DateFormatWrapped.getDateInstance(undefined, oFormatOptionsOrLocale);\n\t\t}\n\n\t\tconst cacheKey = `${JSON.stringify(oFormatOptionsOrLocale ?? {})}__${String(locale)}`;\n\t\tlet instance = _dateFormatCache.get(cacheKey);\n\t\tif (!instance) {\n\t\t\tinstance = DateFormatWrapped.getDateInstance(oFormatOptionsOrLocale, locale);\n\t\t\t_dateFormatCache.set(cacheKey, instance);\n\t\t}\n\t\treturn instance;\n\t}\n}\n\nexport default DateFormat;\n"]}
|
package/dist/Locale.d.ts
ADDED
package/dist/Locale.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Locale.js","sourceRoot":"","sources":["../src/Locale.ts"],"names":[],"mappings":"AACA,aAAa;AACb,OAAO,YAAY,MAAM,yBAAyB,CAAC;AAEnD,MAAM,aAAa,GAAG,YAAqC,CAAC;AAC5D,MAAM,MAAO,SAAQ,aAAa;CAAI;AAEtC,eAAe,MAAM,CAAC","sourcesContent":["import type LocaleOpenUI5T from \"sap/ui/core/Locale\";\n// @ts-ignore\nimport LocaleNative from \"./sap/ui/core/Locale.js\";\n\nconst LocaleWrapped = LocaleNative as typeof LocaleOpenUI5T;\nclass Locale extends LocaleWrapped { }\n\nexport default Locale;\n"]}
|
package/dist/LocaleData.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import LocaleDataNative from "./sap/ui/core/LocaleData.js";
|
|
3
|
+
const LocaleDataWrapped = LocaleDataNative;
|
|
4
|
+
class LocaleData extends LocaleDataWrapped {
|
|
5
|
+
}
|
|
3
6
|
export default LocaleData;
|
|
7
|
+
//# sourceMappingURL=LocaleData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocaleData.js","sourceRoot":"","sources":["../src/LocaleData.ts"],"names":[],"mappings":"AACA,aAAa;AACb,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAE3D,MAAM,iBAAiB,GAAG,gBAA6C,CAAC;AACxE,MAAM,UAAW,SAAQ,iBAAiB;CAAG;AAE7C,eAAe,UAAU,CAAC","sourcesContent":["import type LocaleDataOpenUI5T from \"sap/ui/core/LocaleData\";\n// @ts-ignore\nimport LocaleDataNative from \"./sap/ui/core/LocaleData.js\";\n\nconst LocaleDataWrapped = LocaleDataNative as typeof LocaleDataOpenUI5T;\nclass LocaleData extends LocaleDataWrapped {}\n\nexport default LocaleData;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberFormat.js","sourceRoot":"","sources":["../src/NumberFormat.ts"],"names":[],"mappings":"AACA,aAAa;AACb,OAAO,kBAAkB,MAAM,sCAAsC,CAAC;AAEtE,MAAM,mBAAmB,GAAG,kBAA0C,CAAC;AACvE,MAAM,YAAa,SAAQ,mBAAmB;CAAG;AAEjD,eAAe,YAAY,CAAC","sourcesContent":["import type NumberFormatT from \"sap/ui/core/format/NumberFormat\";\n// @ts-ignore\nimport NumberFormatNative from \"./sap/ui/core/format/NumberFormat.js\";\n\nconst NumberFormatWrapped = NumberFormatNative as typeof NumberFormatT;\nclass NumberFormat extends NumberFormatWrapped {}\n\nexport default NumberFormat;\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
|
|
2
|
+
import UI5Date from "./UI5Date.js";
|
|
3
|
+
import UniversalDate from "./UniversalDate.js";
|
|
4
|
+
declare class CalendarDate {
|
|
5
|
+
_oUDate: UI5Date | Date | UniversalDate;
|
|
6
|
+
constructor(year?: number | CalendarDate, month?: number | string, date?: number, calendarType?: string);
|
|
7
|
+
getYear(): number;
|
|
8
|
+
setYear(year: number): this;
|
|
9
|
+
getMonth(): number;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the given month as ordinal month of the year.
|
|
12
|
+
* @param {int} month An integer between 0 and 11, representing the months January through December( or their
|
|
13
|
+
* equivalent month names for the given calendar).
|
|
14
|
+
* If the specified value is is outside of the expected range, this method attempts to update the date information
|
|
15
|
+
* accordingly. For example, if 12 is given as a month, the year will be incremented by 1, and 1 will be used for month.
|
|
16
|
+
* @param {int} [date] An integer between 1 and 31, representing the day of the month, but other values are allowed.
|
|
17
|
+
* 0 will result in the previous month's last day.
|
|
18
|
+
* -1 will result in the day before the previous month's last day.
|
|
19
|
+
* 32 will result in:
|
|
20
|
+
* - first day of the next month if the current month has 31 days.
|
|
21
|
+
* - second day of the next month if the current month has 30 days.
|
|
22
|
+
* Other value will result in adding or subtracting days according to the given value.
|
|
23
|
+
* @returns {sap.ui.unified.calendar.CalendarDate} <code>this</code> for method chaining.
|
|
24
|
+
*/
|
|
25
|
+
setMonth(month: number, date?: number): this;
|
|
26
|
+
getDate(): number;
|
|
27
|
+
setDate(date: number): this;
|
|
28
|
+
getDay(): number;
|
|
29
|
+
getCalendarType(): string;
|
|
30
|
+
isBefore(oCalendarDate: CalendarDate): boolean;
|
|
31
|
+
isAfter(oCalendarDate: CalendarDate): boolean;
|
|
32
|
+
isSameOrBefore(oCalendarDate: CalendarDate): boolean;
|
|
33
|
+
isSameOrAfter(oCalendarDate: CalendarDate): boolean;
|
|
34
|
+
isSame(oCalendarDate: CalendarDate): boolean;
|
|
35
|
+
toLocalJSDate(): import("sap/ui/core/date/UI5Date").default | Date;
|
|
36
|
+
toUTCJSDate(): import("sap/ui/core/date/UI5Date").default | Date;
|
|
37
|
+
toString(): string;
|
|
38
|
+
valueOf(): number;
|
|
39
|
+
static fromLocalJSDate(oJSDate: Date | UI5Date, sCalendarType?: `${CalendarType}`): CalendarDate;
|
|
40
|
+
static fromTimestamp(iTimestamp: number, sCalendarType?: `${CalendarType}`): CalendarDate;
|
|
41
|
+
}
|
|
42
|
+
export default CalendarDate;
|
|
@@ -1,193 +1,183 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import UI5Date from "./UI5Date.js";
|
|
2
|
+
import UniversalDate from "./UniversalDate.js";
|
|
3
3
|
class CalendarDate {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const oCalDate = new CalendarDate(0, 0, 1);
|
|
160
|
-
oCalDate._oUDate = UniversalDate.getInstance(new Date(iTimestamp), sCalendarType);
|
|
161
|
-
return oCalDate;
|
|
162
|
-
}
|
|
4
|
+
constructor(year, month, date, calendarType) {
|
|
5
|
+
let aArgs = arguments, // eslint-disable-line
|
|
6
|
+
oJSDate, oNow, sCalendarType;
|
|
7
|
+
switch (aArgs.length) {
|
|
8
|
+
case 0: // defaults to the current date
|
|
9
|
+
oNow = UI5Date.getInstance();
|
|
10
|
+
return this.constructor(oNow.getFullYear(), oNow.getMonth(), oNow.getDate());
|
|
11
|
+
case 1: // CalendarDate
|
|
12
|
+
case 2: // CalendarDate, sCalendarType
|
|
13
|
+
if (!(aArgs[0] instanceof CalendarDate)) {
|
|
14
|
+
throw new Error("Invalid arguments: the first argument must be of type CalendarDate.");
|
|
15
|
+
}
|
|
16
|
+
sCalendarType = aArgs[1] ? aArgs[1] : aArgs[0]._oUDate.sCalendarType;
|
|
17
|
+
// Use source.valueOf() (returns the same point of time regardless calendar type) instead of
|
|
18
|
+
// source's getters to avoid non-gregorian Year, Month and Date may be used to construct a Gregorian date
|
|
19
|
+
oJSDate = UI5Date.getInstance(aArgs[0].valueOf());
|
|
20
|
+
// Make this date really local. Now getters are safe.
|
|
21
|
+
oJSDate.setFullYear(oJSDate.getUTCFullYear(), oJSDate.getUTCMonth(), oJSDate.getUTCDate());
|
|
22
|
+
oJSDate.setHours(oJSDate.getUTCHours(), oJSDate.getUTCMinutes(), oJSDate.getUTCSeconds(), oJSDate.getUTCMilliseconds());
|
|
23
|
+
this._oUDate = createUniversalUTCDate(oJSDate, sCalendarType);
|
|
24
|
+
break;
|
|
25
|
+
case 3: // year, month, date
|
|
26
|
+
case 4: // year, month, date, sCalendarType
|
|
27
|
+
checkNumericLike(aArgs[0], `Invalid year: ${aArgs[0]}`);
|
|
28
|
+
checkNumericLike(aArgs[1], `Invalid month: ${aArgs[1]}`);
|
|
29
|
+
checkNumericLike(aArgs[2], `Invalid date: ${aArgs[2]}`);
|
|
30
|
+
oJSDate = UI5Date.getInstance(0, 0, 1);
|
|
31
|
+
oJSDate.setFullYear(aArgs[0], aArgs[1], aArgs[2]); // 2 digits year is not supported. If so, it is considered as full year as well.
|
|
32
|
+
if (aArgs[3]) {
|
|
33
|
+
sCalendarType = aArgs[3];
|
|
34
|
+
}
|
|
35
|
+
this._oUDate = createUniversalUTCDate(oJSDate, sCalendarType);
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
throw new Error(`${"Invalid arguments. Accepted arguments are: 1) oCalendarDate, (optional)calendarType"
|
|
39
|
+
+ "or 2) year, month, date, (optional) calendarType"}${aArgs}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
getYear() {
|
|
43
|
+
return this._oUDate.getUTCFullYear();
|
|
44
|
+
}
|
|
45
|
+
setYear(year) {
|
|
46
|
+
checkNumericLike(year, `Invalid year: ${year}`);
|
|
47
|
+
this._oUDate.setUTCFullYear(year);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
getMonth() {
|
|
51
|
+
return this._oUDate.getUTCMonth();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets the given month as ordinal month of the year.
|
|
55
|
+
* @param {int} month An integer between 0 and 11, representing the months January through December( or their
|
|
56
|
+
* equivalent month names for the given calendar).
|
|
57
|
+
* If the specified value is is outside of the expected range, this method attempts to update the date information
|
|
58
|
+
* accordingly. For example, if 12 is given as a month, the year will be incremented by 1, and 1 will be used for month.
|
|
59
|
+
* @param {int} [date] An integer between 1 and 31, representing the day of the month, but other values are allowed.
|
|
60
|
+
* 0 will result in the previous month's last day.
|
|
61
|
+
* -1 will result in the day before the previous month's last day.
|
|
62
|
+
* 32 will result in:
|
|
63
|
+
* - first day of the next month if the current month has 31 days.
|
|
64
|
+
* - second day of the next month if the current month has 30 days.
|
|
65
|
+
* Other value will result in adding or subtracting days according to the given value.
|
|
66
|
+
* @returns {sap.ui.unified.calendar.CalendarDate} <code>this</code> for method chaining.
|
|
67
|
+
*/
|
|
68
|
+
setMonth(month, date) {
|
|
69
|
+
checkNumericLike(month, `Invalid month: ${month}`);
|
|
70
|
+
if (date || date === 0) {
|
|
71
|
+
checkNumericLike(date, `Invalid date: ${date}`);
|
|
72
|
+
this._oUDate.setUTCMonth(month, date);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this._oUDate.setUTCMonth(month);
|
|
76
|
+
}
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
getDate() {
|
|
80
|
+
return this._oUDate.getUTCDate();
|
|
81
|
+
}
|
|
82
|
+
setDate(date) {
|
|
83
|
+
checkNumericLike(date, `Invalid date: ${date}`);
|
|
84
|
+
this._oUDate.setUTCDate(date);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
getDay() {
|
|
88
|
+
return this._oUDate.getUTCDay();
|
|
89
|
+
}
|
|
90
|
+
getCalendarType() {
|
|
91
|
+
return this._oUDate.sCalendarType;
|
|
92
|
+
}
|
|
93
|
+
isBefore(oCalendarDate) {
|
|
94
|
+
checkCalendarDate(oCalendarDate);
|
|
95
|
+
return this.valueOf() < oCalendarDate.valueOf();
|
|
96
|
+
}
|
|
97
|
+
isAfter(oCalendarDate) {
|
|
98
|
+
checkCalendarDate(oCalendarDate);
|
|
99
|
+
return this.valueOf() > oCalendarDate.valueOf();
|
|
100
|
+
}
|
|
101
|
+
isSameOrBefore(oCalendarDate) {
|
|
102
|
+
checkCalendarDate(oCalendarDate);
|
|
103
|
+
return this.valueOf() <= oCalendarDate.valueOf();
|
|
104
|
+
}
|
|
105
|
+
isSameOrAfter(oCalendarDate) {
|
|
106
|
+
checkCalendarDate(oCalendarDate);
|
|
107
|
+
return this.valueOf() >= oCalendarDate.valueOf();
|
|
108
|
+
}
|
|
109
|
+
isSame(oCalendarDate) {
|
|
110
|
+
checkCalendarDate(oCalendarDate);
|
|
111
|
+
return this.valueOf() === oCalendarDate.valueOf();
|
|
112
|
+
}
|
|
113
|
+
toLocalJSDate() {
|
|
114
|
+
// Use this._oUDate.getTime()(returns the same point of time regardless calendar type) instead of
|
|
115
|
+
// this._oUDate's getters to avoid non-gregorian Year, Month and Date to be used to construct a Gregorian date
|
|
116
|
+
const oLocalDate = UI5Date.getInstance(this._oUDate.getTime());
|
|
117
|
+
// Make this date really local. Now getters are safe.
|
|
118
|
+
oLocalDate.setFullYear(oLocalDate.getUTCFullYear(), oLocalDate.getUTCMonth(), oLocalDate.getUTCDate());
|
|
119
|
+
oLocalDate.setHours(0, 0, 0, 0);
|
|
120
|
+
return oLocalDate;
|
|
121
|
+
}
|
|
122
|
+
toUTCJSDate() {
|
|
123
|
+
// Use this._oUDate.getTime()(returns the same point of time regardless calendar type) instead of
|
|
124
|
+
// this._oUDate's getters to avoid non-gregorian Year, Month and Date to be used to construct a Gregorian date
|
|
125
|
+
const oUTCDate = UI5Date.getInstance(this._oUDate.getTime());
|
|
126
|
+
oUTCDate.setUTCHours(0, 0, 0, 0);
|
|
127
|
+
return oUTCDate;
|
|
128
|
+
}
|
|
129
|
+
toString() {
|
|
130
|
+
return `${this._oUDate.sCalendarType}: ${this.getYear()}/${this.getMonth() + 1}/${this.getDate()}`;
|
|
131
|
+
}
|
|
132
|
+
valueOf() {
|
|
133
|
+
return this._oUDate.getTime();
|
|
134
|
+
}
|
|
135
|
+
static fromLocalJSDate(oJSDate, sCalendarType) {
|
|
136
|
+
// Cross frame check for a date should be performed here otherwise setDateValue would fail in OPA tests
|
|
137
|
+
// because Date object in the test is different than the Date object in the application (due to the iframe).
|
|
138
|
+
// We can use jQuery.type or this method:
|
|
139
|
+
function isValidDate(date) {
|
|
140
|
+
return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date); // eslint-disable-line
|
|
141
|
+
}
|
|
142
|
+
if (!isValidDate(oJSDate)) {
|
|
143
|
+
throw new Error(`Date parameter must be a JavaScript Date object: [${oJSDate}].`);
|
|
144
|
+
}
|
|
145
|
+
return new CalendarDate(oJSDate.getFullYear(), oJSDate.getMonth(), oJSDate.getDate(), sCalendarType);
|
|
146
|
+
}
|
|
147
|
+
static fromTimestamp(iTimestamp, sCalendarType) {
|
|
148
|
+
const oCalDate = new CalendarDate(0, 0, 1);
|
|
149
|
+
let oUDate;
|
|
150
|
+
try {
|
|
151
|
+
oUDate = UniversalDate.getInstance(UI5Date.getInstance(iTimestamp), sCalendarType);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
oUDate = new Date(NaN); // UniversalDate.getInstance may now throw an Exception - keep the old behavior
|
|
155
|
+
}
|
|
156
|
+
oCalDate._oUDate = oUDate;
|
|
157
|
+
return oCalDate;
|
|
158
|
+
}
|
|
163
159
|
}
|
|
164
|
-
|
|
165
160
|
function createUniversalUTCDate(oDate, sCalendarType) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
if (sCalendarType) {
|
|
162
|
+
return UniversalDate.getInstance(createUTCDate(oDate), sCalendarType);
|
|
163
|
+
}
|
|
164
|
+
return new UniversalDate(createUTCDate(oDate).getTime());
|
|
170
165
|
}
|
|
171
|
-
|
|
172
166
|
/**
|
|
173
167
|
* Creates a JavaScript UTC Date corresponding to the given JavaScript Date.
|
|
174
168
|
* @param {Date} oDate JavaScript date object. Time related information is cut.
|
|
175
169
|
* @returns {Date} JavaScript date created from the date object, but this time considered as UTC date information.
|
|
176
170
|
*/
|
|
177
171
|
function createUTCDate(oDate) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return oUTCDate;
|
|
172
|
+
const oUTCDate = new Date(Date.UTC(0, 0, 1)); // no need to replace with UI5Date as we are creating a new UTC date object
|
|
173
|
+
oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
|
|
174
|
+
return oUTCDate;
|
|
183
175
|
}
|
|
184
|
-
|
|
185
176
|
function checkCalendarDate(oCalendarDate) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
177
|
+
if (!(oCalendarDate instanceof CalendarDate)) {
|
|
178
|
+
throw new Error(`Invalid calendar date: [${oCalendarDate}]. Expected: CalendarDate`);
|
|
179
|
+
}
|
|
189
180
|
}
|
|
190
|
-
|
|
191
181
|
/**
|
|
192
182
|
* Verifies the given value is numeric like, i.e. 3, "3" and throws an error if it is not.
|
|
193
183
|
* @param {any} value The value of any type to check. If null or undefined, this method throws an error.
|
|
@@ -195,9 +185,9 @@ function checkCalendarDate(oCalendarDate) {
|
|
|
195
185
|
* @throws will throw an error if the value is null or undefined or is not like a number
|
|
196
186
|
*/
|
|
197
187
|
function checkNumericLike(value, message) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
188
|
+
if (value === undefined || value === Infinity || isNaN(value)) { // eslint-disable-line
|
|
189
|
+
throw message;
|
|
190
|
+
}
|
|
201
191
|
}
|
|
202
|
-
|
|
203
192
|
export default CalendarDate;
|
|
193
|
+
//# sourceMappingURL=CalendarDate.js.map
|