@ui5/webcomponents-localization 0.0.0-ef27ca1aa → 0.0.0-f24ff9019

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.
Files changed (199) hide show
  1. package/.eslintignore +1 -0
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +702 -0
  4. package/README.md +37 -6
  5. package/dist/Assets-static.d.ts +1 -0
  6. package/dist/Assets-static.js +3 -0
  7. package/dist/Assets-static.js.map +1 -0
  8. package/dist/Assets.d.ts +1 -0
  9. package/dist/Assets.js +1 -0
  10. package/dist/Assets.js.map +1 -0
  11. package/dist/DateFormat.d.ts +6 -0
  12. package/dist/DateFormat.js +6 -2
  13. package/dist/DateFormat.js.map +1 -0
  14. package/dist/LocaleData.d.ts +6 -0
  15. package/dist/LocaleData.js +6 -2
  16. package/dist/LocaleData.js.map +1 -0
  17. package/dist/dates/CalendarDate.d.ts +43 -0
  18. package/dist/dates/CalendarDate.js +171 -181
  19. package/dist/dates/CalendarDate.js.map +1 -0
  20. package/dist/dates/ExtremeDates.d.ts +5 -0
  21. package/dist/dates/ExtremeDates.js +29 -0
  22. package/dist/dates/ExtremeDates.js.map +1 -0
  23. package/dist/dates/UI5Date.d.ts +6 -0
  24. package/dist/dates/UI5Date.js +7 -0
  25. package/dist/dates/UI5Date.js.map +1 -0
  26. package/dist/dates/UniversalDate.d.ts +47 -0
  27. package/dist/dates/UniversalDate.js +5 -0
  28. package/dist/dates/UniversalDate.js.map +1 -0
  29. package/dist/dates/calculateWeekNumber.d.ts +5 -0
  30. package/dist/dates/calculateWeekNumber.js +42 -48
  31. package/dist/dates/calculateWeekNumber.js.map +1 -0
  32. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  33. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  34. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  35. package/dist/dates/getDaysInMonth.d.ts +3 -0
  36. package/dist/dates/getDaysInMonth.js +10 -0
  37. package/dist/dates/getDaysInMonth.js.map +1 -0
  38. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  39. package/dist/dates/getRoundedTimestamp.js +15 -0
  40. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  41. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  42. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  43. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  44. package/dist/dates/modifyDateBy.d.ts +14 -0
  45. package/dist/dates/modifyDateBy.js +55 -0
  46. package/dist/dates/modifyDateBy.js.map +1 -0
  47. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  48. package/dist/dates/transformDateToSecondaryType.js +18 -0
  49. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  50. package/dist/features/calendar/Buddhist.js +1 -0
  51. package/dist/features/calendar/Buddhist.js.map +1 -0
  52. package/dist/features/calendar/Gregorian.js +1 -0
  53. package/dist/features/calendar/Gregorian.js.map +1 -0
  54. package/dist/features/calendar/Islamic.js +1 -0
  55. package/dist/features/calendar/Islamic.js.map +1 -0
  56. package/dist/features/calendar/Japanese.js +1 -0
  57. package/dist/features/calendar/Japanese.js.map +1 -0
  58. package/dist/features/calendar/Persian.js +1 -0
  59. package/dist/features/calendar/Persian.js.map +1 -0
  60. package/dist/generated/assets/cldr/ar.json +5531 -5904
  61. package/dist/generated/assets/cldr/ar_EG.json +5531 -5904
  62. package/dist/generated/assets/cldr/ar_SA.json +5530 -5904
  63. package/dist/generated/assets/cldr/bg.json +4452 -4977
  64. package/dist/generated/assets/cldr/ca.json +4440 -4994
  65. package/dist/generated/assets/cldr/cs.json +4960 -5496
  66. package/dist/generated/assets/cldr/cy.json +5213 -0
  67. package/dist/generated/assets/cldr/da.json +4308 -4886
  68. package/dist/generated/assets/cldr/de.json +4313 -4914
  69. package/dist/generated/assets/cldr/de_AT.json +4314 -4915
  70. package/dist/generated/assets/cldr/de_CH.json +4312 -4913
  71. package/dist/generated/assets/cldr/el.json +4281 -4881
  72. package/dist/generated/assets/cldr/el_CY.json +4281 -4881
  73. package/dist/generated/assets/cldr/en.json +4316 -4968
  74. package/dist/generated/assets/cldr/en_AU.json +4319 -4960
  75. package/dist/generated/assets/cldr/en_GB.json +4329 -4969
  76. package/dist/generated/assets/cldr/en_HK.json +4337 -4975
  77. package/dist/generated/assets/cldr/en_IE.json +4328 -4969
  78. package/dist/generated/assets/cldr/en_IN.json +4333 -4970
  79. package/dist/generated/assets/cldr/en_NZ.json +4328 -4969
  80. package/dist/generated/assets/cldr/en_PG.json +4329 -4970
  81. package/dist/generated/assets/cldr/en_SG.json +4333 -4971
  82. package/dist/generated/assets/cldr/en_ZA.json +4329 -4970
  83. package/dist/generated/assets/cldr/es.json +4331 -4910
  84. package/dist/generated/assets/cldr/es_AR.json +4334 -4912
  85. package/dist/generated/assets/cldr/es_BO.json +4333 -4911
  86. package/dist/generated/assets/cldr/es_CL.json +4334 -4912
  87. package/dist/generated/assets/cldr/es_CO.json +4333 -4911
  88. package/dist/generated/assets/cldr/es_MX.json +4335 -4913
  89. package/dist/generated/assets/cldr/es_PE.json +4333 -4911
  90. package/dist/generated/assets/cldr/es_UY.json +4335 -4913
  91. package/dist/generated/assets/cldr/es_VE.json +4334 -4912
  92. package/dist/generated/assets/cldr/et.json +4340 -4965
  93. package/dist/generated/assets/cldr/fa.json +4367 -4881
  94. package/dist/generated/assets/cldr/fi.json +4463 -5006
  95. package/dist/generated/assets/cldr/fr.json +4357 -4977
  96. package/dist/generated/assets/cldr/fr_BE.json +4357 -4977
  97. package/dist/generated/assets/cldr/fr_CA.json +4351 -4971
  98. package/dist/generated/assets/cldr/fr_CH.json +4375 -4995
  99. package/dist/generated/assets/cldr/fr_LU.json +4357 -4977
  100. package/dist/generated/assets/cldr/he.json +4869 -5376
  101. package/dist/generated/assets/cldr/hi.json +4295 -4827
  102. package/dist/generated/assets/cldr/hr.json +4583 -4917
  103. package/dist/generated/assets/cldr/hu.json +4364 -4854
  104. package/dist/generated/assets/cldr/id.json +4060 -4656
  105. package/dist/generated/assets/cldr/it.json +4299 -4948
  106. package/dist/generated/assets/cldr/it_CH.json +4299 -4948
  107. package/dist/generated/assets/cldr/ja.json +4211 -4828
  108. package/dist/generated/assets/cldr/kk.json +4339 -4723
  109. package/dist/generated/assets/cldr/ko.json +4189 -4736
  110. package/dist/generated/assets/cldr/lt.json +4850 -5479
  111. package/dist/generated/assets/cldr/lv.json +4587 -5110
  112. package/dist/generated/assets/cldr/ms.json +4021 -4513
  113. package/dist/generated/assets/cldr/nb.json +4335 -4975
  114. package/dist/generated/assets/cldr/nl.json +4294 -4882
  115. package/dist/generated/assets/cldr/nl_BE.json +4294 -4882
  116. package/dist/generated/assets/cldr/pl.json +4667 -5174
  117. package/dist/generated/assets/cldr/pt.json +4235 -4803
  118. package/dist/generated/assets/cldr/pt_PT.json +4372 -4938
  119. package/dist/generated/assets/cldr/ro.json +4563 -5088
  120. package/dist/generated/assets/cldr/ru.json +4909 -5405
  121. package/dist/generated/assets/cldr/ru_UA.json +4909 -5405
  122. package/dist/generated/assets/cldr/sk.json +4939 -5368
  123. package/dist/generated/assets/cldr/sl.json +4910 -5338
  124. package/dist/generated/assets/cldr/sr.json +4585 -5124
  125. package/dist/generated/assets/cldr/sr_Latn.json +4576 -0
  126. package/dist/generated/assets/cldr/sv.json +4362 -5009
  127. package/dist/generated/assets/cldr/th.json +4214 -4795
  128. package/dist/generated/assets/cldr/tr.json +4400 -4977
  129. package/dist/generated/assets/cldr/uk.json +4858 -5351
  130. package/dist/generated/assets/cldr/vi.json +4070 -4671
  131. package/dist/generated/assets/cldr/zh_CN.json +4100 -4630
  132. package/dist/generated/assets/cldr/zh_HK.json +4108 -4638
  133. package/dist/generated/assets/cldr/zh_SG.json +4108 -4638
  134. package/dist/generated/assets/cldr/zh_TW.json +4131 -4726
  135. package/dist/generated/json-imports/LocaleData-static.js +90 -0
  136. package/dist/generated/json-imports/LocaleData.js +88 -91
  137. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  138. package/dist/getCachedLocaleDataInstance.js +10 -0
  139. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  140. package/dist/locale/getLocaleData.d.ts +11 -0
  141. package/dist/locale/getLocaleData.js +13 -17
  142. package/dist/locale/getLocaleData.js.map +1 -0
  143. package/dist/sap/base/Log.js +28 -37
  144. package/dist/sap/base/assert.js +5 -10
  145. package/dist/sap/base/i18n/LanguageTag.js +35 -0
  146. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  147. package/dist/sap/base/i18n/Localization.js +12 -0
  148. package/dist/sap/base/i18n/Localization.js.map +1 -0
  149. package/dist/sap/base/i18n/date/CalendarType.js +8 -0
  150. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +30 -0
  151. package/dist/sap/base/i18n/date/TimezoneUtils.js +89 -0
  152. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  153. package/dist/sap/base/util/LoaderExtensions.js +11 -4
  154. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  155. package/dist/sap/base/util/array/uniqueSort.js +7 -7
  156. package/dist/sap/base/util/deepEqual.js +1 -5
  157. package/dist/sap/ui/base/Interface.js +3 -5
  158. package/dist/sap/ui/base/Metadata.js +21 -12
  159. package/dist/sap/ui/base/Object.js +26 -2
  160. package/dist/sap/ui/core/CalendarType.js +2 -8
  161. package/dist/sap/ui/core/Configuration.d.ts +18 -0
  162. package/dist/sap/ui/core/Configuration.js +23 -0
  163. package/dist/sap/ui/core/Configuration.js.map +1 -0
  164. package/dist/sap/ui/core/Core.d.ts +27 -0
  165. package/dist/sap/ui/core/Core.js +7 -32
  166. package/dist/sap/ui/core/Core.js.map +1 -0
  167. package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
  168. package/dist/sap/ui/core/FormatSettings.js +14 -0
  169. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  170. package/dist/sap/ui/core/Locale.js +28 -86
  171. package/dist/sap/ui/core/LocaleData.js +237 -1538
  172. package/dist/sap/ui/core/date/Buddhist.js +0 -6
  173. package/dist/sap/ui/core/date/CalendarUtils.js +25 -0
  174. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +2 -0
  175. package/dist/sap/ui/core/date/Islamic.js +3 -3
  176. package/dist/sap/ui/core/date/Japanese.js +4 -4
  177. package/dist/sap/ui/core/date/UI5Date.js +305 -0
  178. package/dist/sap/ui/core/date/UniversalDate.js +74 -25
  179. package/dist/sap/ui/core/format/DateFormat.js +881 -517
  180. package/dist/sap/ui/core/format/TimezoneUtil.js +2 -0
  181. package/package-scripts.cjs +37 -0
  182. package/package.json +14 -13
  183. package/tsconfig.json +14 -0
  184. package/used-modules.txt +9 -1
  185. package/package-scripts.js +0 -31
  186. package/src/Assets.js +0 -2
  187. package/src/DateFormat.js +0 -3
  188. package/src/LocaleData.js +0 -3
  189. package/src/dates/CalendarDate.js +0 -203
  190. package/src/dates/calculateWeekNumber.js +0 -51
  191. package/src/locale/getLocaleData.js +0 -27
  192. package/src/sap/base/util/LoaderExtensions.js +0 -7
  193. package/src/sap/ui/core/Core.js +0 -38
  194. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  195. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  196. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  197. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  198. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  199. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
package/README.md CHANGED
@@ -1,23 +1,54 @@
1
- ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/master/docs/images/UI5_logo_wide.png)
1
+ ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_wide.png)
2
+
2
3
 
3
4
  # UI5 Web Components - Localization
4
5
 
5
- [![Travis CI Build Status](https://travis-ci.org/SAP/ui5-webcomponents.svg?branch=master)](https://travis-ci.org/SAP/ui5-webcomponents)
6
6
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)
7
7
 
8
8
  Provides date/time and CLDR functionality for the purposes of building UI5 Web Components.
9
9
 
10
+ ## Provided assets
11
+
12
+ The assets, provided by this package, are CLDR data:
13
+
14
+ `import "@ui5/webcomponents-localization/dist/Assets.js";`
15
+
16
+ *Note:* These assets are already imported by the UI5 Web Components packages that need them.
17
+
18
+ ## Provided features
19
+
20
+ | Feature Import | Description |
21
+ |----------------------------------------------------------------------|---------------------------|
22
+ | `@ui5/webcomponents-localization/dist/features/calendar/Buddhist.js` | Buddhist calendar support |
23
+ | `@ui5/webcomponents-localization/dist/features/calendar/Islamic.js` | Islamic calendar support |
24
+ | `@ui5/webcomponents-localization/dist/features/calendar/Japanese.js` | Japanese calendar support |
25
+ | `@ui5/webcomponents-localization/dist/features/calendar/Persian.js` | Persian calendar support |
26
+
27
+ ### Advanced Calendar Types Feature
28
+
29
+ ```js
30
+ import "@ui5/webcomponents-localization/dist/features/calendar/Buddhist.js";
31
+ import "@ui5/webcomponents-localization/dist/features/calendar/Islamic.js";
32
+ import "@ui5/webcomponents-localization/dist/features/calendar/Japanese.js";
33
+ import "@ui5/webcomponents-localization/dist/features/calendar/Persian.js";
34
+ ```
35
+
36
+ The `ui5-date-picker` and `ui5-datetime-picker` components supports Gregorian Calendar by default.
37
+
38
+ In order to be able to use Buddhist, Islamic, Japanese, or Persian calendar with these components
39
+ (by setting its `primaryCalendarType` property), you must import one or more of the modules above.
40
+
10
41
  ## Resources
11
- - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/master/README.md)
42
+ - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
12
43
  - [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
13
44
  - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
14
45
 
15
46
  ## Support
16
- We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
47
+ We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
17
48
 
18
49
  ## Contribute
19
- Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/CONTRIBUTING.md).
50
+ Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).
20
51
 
21
52
  ## License
22
53
  Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
23
- This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the [LICENSE](https://github.com/SAP/ui5-webcomponents/blob/master/LICENSE.txt) file.
54
+ This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the [LICENSE](https://github.com/SAP/ui5-webcomponents/blob/main/LICENSE.txt) file.
@@ -0,0 +1 @@
1
+ import "./generated/json-imports/LocaleData-static.js";
@@ -0,0 +1,3 @@
1
+ // Currently the base package provides CLDR assets only
2
+ import "./generated/json-imports/LocaleData-static.js";
3
+ //# sourceMappingURL=Assets-static.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assets-static.js","sourceRoot":"","sources":["../src/Assets-static.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,+CAA+C,CAAC","sourcesContent":["// Currently the base package provides CLDR assets only\nimport \"./generated/json-imports/LocaleData-static.js\";\n"]}
@@ -0,0 +1 @@
1
+ import "./generated/json-imports/LocaleData.js";
package/dist/Assets.js CHANGED
@@ -1,2 +1,3 @@
1
1
  // Currently the base package provides CLDR assets only
2
2
  import "./generated/json-imports/LocaleData.js";
3
+ //# sourceMappingURL=Assets.js.map
@@ -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,6 @@
1
+ /// <reference types="openui5" />
2
+ import type DateFormatT from "sap/ui/core/format/DateFormat";
3
+ declare const DateFormatWrapped: typeof DateFormatT;
4
+ declare class DateFormat extends DateFormatWrapped {
5
+ }
6
+ export default DateFormat;
@@ -1,3 +1,7 @@
1
- import DateFormat from "./sap/ui/core/format/DateFormat.js";
2
-
1
+ // @ts-ignore
2
+ import DateFormatNative from "./sap/ui/core/format/DateFormat.js";
3
+ const DateFormatWrapped = DateFormatNative;
4
+ class DateFormat extends DateFormatWrapped {
5
+ }
3
6
  export default DateFormat;
7
+ //# 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;AAElE,MAAM,iBAAiB,GAAG,gBAAsC,CAAC;AACjE,MAAM,UAAW,SAAQ,iBAAiB;CAAG;AAE7C,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\";\n\nconst DateFormatWrapped = DateFormatNative as typeof DateFormatT;\nclass DateFormat extends DateFormatWrapped {}\n\nexport default DateFormat;\n"]}
@@ -0,0 +1,6 @@
1
+ /// <reference types="openui5" />
2
+ import type LocaleDataOpenUI5T from "sap/ui/core/LocaleData";
3
+ declare const LocaleDataWrapped: typeof LocaleDataOpenUI5T;
4
+ declare class LocaleData extends LocaleDataWrapped {
5
+ }
6
+ export default LocaleData;
@@ -1,3 +1,7 @@
1
- import LocaleData from "./sap/ui/core/LocaleData.js";
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,43 @@
1
+ /// <reference types="openui5" />
2
+ import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
3
+ import UI5Date from "./UI5Date.js";
4
+ import UniversalDate from "./UniversalDate.js";
5
+ declare class CalendarDate {
6
+ _oUDate: UI5Date | Date | UniversalDate;
7
+ constructor(year?: number | CalendarDate, month?: number | string, date?: number, calendarType?: string);
8
+ getYear(): number;
9
+ setYear(year: number): this;
10
+ getMonth(): number;
11
+ /**
12
+ * Sets the given month as ordinal month of the year.
13
+ * @param {int} month An integer between 0 and 11, representing the months January through December( or their
14
+ * equivalent month names for the given calendar).
15
+ * If the specified value is is outside of the expected range, this method attempts to update the date information
16
+ * accordingly. For example, if 12 is given as a month, the year will be incremented by 1, and 1 will be used for month.
17
+ * @param {int} [date] An integer between 1 and 31, representing the day of the month, but other values are allowed.
18
+ * 0 will result in the previous month's last day.
19
+ * -1 will result in the day before the previous month's last day.
20
+ * 32 will result in:
21
+ * - first day of the next month if the current month has 31 days.
22
+ * - second day of the next month if the current month has 30 days.
23
+ * Other value will result in adding or subtracting days according to the given value.
24
+ * @returns {sap.ui.unified.calendar.CalendarDate} <code>this</code> for method chaining.
25
+ */
26
+ setMonth(month: number, date?: number): this;
27
+ getDate(): number;
28
+ setDate(date: number): this;
29
+ getDay(): number;
30
+ getCalendarType(): string;
31
+ isBefore(oCalendarDate: CalendarDate): boolean;
32
+ isAfter(oCalendarDate: CalendarDate): boolean;
33
+ isSameOrBefore(oCalendarDate: CalendarDate): boolean;
34
+ isSameOrAfter(oCalendarDate: CalendarDate): boolean;
35
+ isSame(oCalendarDate: CalendarDate): boolean;
36
+ toLocalJSDate(): import("sap/ui/core/date/UI5Date").default | Date;
37
+ toUTCJSDate(): import("sap/ui/core/date/UI5Date").default | Date;
38
+ toString(): string;
39
+ valueOf(): number;
40
+ static fromLocalJSDate(oJSDate: Date | UI5Date, sCalendarType?: `${CalendarType}`): CalendarDate;
41
+ static fromTimestamp(iTimestamp: number, sCalendarType?: `${CalendarType}`): CalendarDate;
42
+ }
43
+ export default CalendarDate;
@@ -1,193 +1,183 @@
1
- import UniversalDate from "../sap/ui/core/date/UniversalDate.js";
2
-
1
+ import UI5Date from "./UI5Date.js";
2
+ import UniversalDate from "./UniversalDate.js";
3
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
- }
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
- if (sCalendarType) {
167
- return UniversalDate.getInstance(createUTCDate(oDate), sCalendarType);
168
- }
169
- return new UniversalDate(createUTCDate(oDate).getTime());
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
- const oUTCDate = new Date(Date.UTC(0, 0, 1));
179
-
180
- oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
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
- if (!(oCalendarDate instanceof CalendarDate)) {
187
- throw new Error(`Invalid calendar date: [${oCalendarDate}]. Expected: sap.ui.unified.calendar.CalendarDate`);
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
- if (value === undefined || value === Infinity || isNaN(value)) { // eslint-disable-line
199
- throw message;
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cal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AM,CAAC;QAC1B,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AAED,SAAS,sBAAsB,CAAC,KAAqB,EAAE,aAAgC;IACtF,IAAI,aAAa,EAAE;QAClB,OAAO,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,CAAC;KACtE;IACD,OAAO,IAAI,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,KAAqB;IAC3C,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,2EAA2E;IAEzH,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEhF,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,SAAS,iBAAiB,CAAC,aAA2B;IACrD,IAAI,CAAC,CAAC,aAAa,YAAY,YAAY,CAAC,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,2BAA2B,aAAkC,2BAA2B,CAAC,CAAC;KAC1G;AACF,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,KAAU,EAAE,OAAe;IACpD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,sBAAsB;QACtF,MAAM,OAAO,CAAC;KACd;AACF,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["import type CalendarType from \"@ui5/webcomponents-base/dist/types/CalendarType.js\";\nimport UI5Date from \"./UI5Date.js\";\nimport UniversalDate from \"./UniversalDate.js\";\n\nclass CalendarDate {\n\t_oUDate!: UI5Date | Date | UniversalDate;\n\n\tconstructor(year?: number | CalendarDate, month?: number | string, date?: number, calendarType?: string) { // eslint-disable-line\n\t\tlet aArgs = arguments, // eslint-disable-line\n\t\t\toJSDate: UI5Date | Date,\n\t\t\toNow: UI5Date | Date,\n\t\t\tsCalendarType!: CalendarType;\n\n\t\tswitch (aArgs.length) {\n\t\tcase 0: // defaults to the current date\n\t\t\toNow = UI5Date.getInstance();\n\t\t\treturn (this.constructor(oNow.getFullYear(), oNow.getMonth(), oNow.getDate()) as CalendarDate);\n\n\t\tcase 1: // CalendarDate\n\t\tcase 2: // CalendarDate, sCalendarType\n\t\t\tif (!(aArgs[0] instanceof CalendarDate)) {\n\t\t\t\tthrow new Error(\"Invalid arguments: the first argument must be of type CalendarDate.\");\n\t\t\t}\n\t\t\tsCalendarType = aArgs[1] ? aArgs[1] : (aArgs[0]._oUDate as UniversalDate).sCalendarType;\n\t\t\t// Use source.valueOf() (returns the same point of time regardless calendar type) instead of\n\t\t\t// source's getters to avoid non-gregorian Year, Month and Date may be used to construct a Gregorian date\n\t\t\toJSDate = UI5Date.getInstance(aArgs[0].valueOf());\n\n\t\t\t// Make this date really local. Now getters are safe.\n\t\t\toJSDate.setFullYear(oJSDate.getUTCFullYear(), oJSDate.getUTCMonth(), oJSDate.getUTCDate());\n\t\t\toJSDate.setHours(oJSDate.getUTCHours(), oJSDate.getUTCMinutes(), oJSDate.getUTCSeconds(), oJSDate.getUTCMilliseconds());\n\n\t\t\tthis._oUDate = createUniversalUTCDate(oJSDate, sCalendarType);\n\t\t\tbreak;\n\n\t\tcase 3: // year, month, date\n\t\tcase 4: // year, month, date, sCalendarType\n\t\t\tcheckNumericLike(aArgs[0] as number, `Invalid year: ${aArgs[0] as number}`);\n\t\t\tcheckNumericLike(aArgs[1] as number, `Invalid month: ${aArgs[1] as number}`);\n\t\t\tcheckNumericLike(aArgs[2] as number, `Invalid date: ${aArgs[2] as number}`);\n\n\t\t\toJSDate = UI5Date.getInstance(0, 0, 1);\n\t\t\toJSDate.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.\n\n\t\t\tif (aArgs[3]) {\n\t\t\t\tsCalendarType = aArgs[3];\n\t\t\t}\n\t\t\tthis._oUDate = createUniversalUTCDate(oJSDate, sCalendarType);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tthrow new Error(`${\"Invalid arguments. Accepted arguments are: 1) oCalendarDate, (optional)calendarType\"\n\t\t\t\t+ \"or 2) year, month, date, (optional) calendarType\"}${aArgs as unknown as string}`);\n\t\t}\n\t}\n\n\tgetYear() {\n\t\treturn this._oUDate.getUTCFullYear();\n\t}\n\n\tsetYear(year: number) {\n\t\tcheckNumericLike(year, `Invalid year: ${year}`);\n\t\tthis._oUDate.setUTCFullYear(year);\n\t\treturn this;\n\t}\n\n\tgetMonth() {\n\t\treturn this._oUDate.getUTCMonth();\n\t}\n\n\t/**\n\t * Sets the given month as ordinal month of the year.\n\t * @param {int} month An integer between 0 and 11, representing the months January through December( or their\n\t * equivalent month names for the given calendar).\n\t * If the specified value is is outside of the expected range, this method attempts to update the date information\n\t * accordingly. For example, if 12 is given as a month, the year will be incremented by 1, and 1 will be used for month.\n\t * @param {int} [date] An integer between 1 and 31, representing the day of the month, but other values are allowed.\n\t * 0 will result in the previous month's last day.\n\t * -1 will result in the day before the previous month's last day.\n\t * 32 will result in:\n\t * - first day of the next month if the current month has 31 days.\n\t * - second day of the next month if the current month has 30 days.\n\t * Other value will result in adding or subtracting days according to the given value.\n\t * @returns {sap.ui.unified.calendar.CalendarDate} <code>this</code> for method chaining.\n\t */\n\tsetMonth(month: number, date?: number) {\n\t\tcheckNumericLike(month, `Invalid month: ${month}`);\n\t\tif (date || date === 0) {\n\t\t\tcheckNumericLike(date, `Invalid date: ${date}`);\n\t\t\tthis._oUDate.setUTCMonth(month, date);\n\t\t} else {\n\t\t\tthis._oUDate.setUTCMonth(month);\n\t\t}\n\t\treturn this;\n\t}\n\n\tgetDate() {\n\t\treturn this._oUDate.getUTCDate();\n\t}\n\n\tsetDate(date: number) {\n\t\tcheckNumericLike(date, `Invalid date: ${date}`);\n\t\tthis._oUDate.setUTCDate(date);\n\t\treturn this;\n\t}\n\n\tgetDay() {\n\t\treturn this._oUDate.getUTCDay();\n\t}\n\n\tgetCalendarType() {\n\t\treturn (this._oUDate as UniversalDate).sCalendarType;\n\t}\n\n\tisBefore(oCalendarDate: CalendarDate) {\n\t\tcheckCalendarDate(oCalendarDate);\n\t\treturn this.valueOf() < oCalendarDate.valueOf();\n\t}\n\n\tisAfter(oCalendarDate: CalendarDate) {\n\t\tcheckCalendarDate(oCalendarDate);\n\t\treturn this.valueOf() > oCalendarDate.valueOf();\n\t}\n\n\tisSameOrBefore(oCalendarDate: CalendarDate) {\n\t\tcheckCalendarDate(oCalendarDate);\n\t\treturn this.valueOf() <= oCalendarDate.valueOf();\n\t}\n\n\tisSameOrAfter(oCalendarDate: CalendarDate) {\n\t\tcheckCalendarDate(oCalendarDate);\n\t\treturn this.valueOf() >= oCalendarDate.valueOf();\n\t}\n\n\tisSame(oCalendarDate: CalendarDate) {\n\t\tcheckCalendarDate(oCalendarDate);\n\t\treturn this.valueOf() === oCalendarDate.valueOf();\n\t}\n\n\ttoLocalJSDate() {\n\t\t// Use this._oUDate.getTime()(returns the same point of time regardless calendar type) instead of\n\t\t// this._oUDate's getters to avoid non-gregorian Year, Month and Date to be used to construct a Gregorian date\n\t\tconst oLocalDate = UI5Date.getInstance(this._oUDate.getTime());\n\n\t\t// Make this date really local. Now getters are safe.\n\t\toLocalDate.setFullYear(oLocalDate.getUTCFullYear(), oLocalDate.getUTCMonth(), oLocalDate.getUTCDate());\n\t\toLocalDate.setHours(0, 0, 0, 0);\n\n\t\treturn oLocalDate;\n\t}\n\n\ttoUTCJSDate() {\n\t\t// Use this._oUDate.getTime()(returns the same point of time regardless calendar type) instead of\n\t\t// this._oUDate's getters to avoid non-gregorian Year, Month and Date to be used to construct a Gregorian date\n\t\tconst oUTCDate = UI5Date.getInstance(this._oUDate.getTime());\n\t\toUTCDate.setUTCHours(0, 0, 0, 0);\n\n\t\treturn oUTCDate;\n\t}\n\n\ttoString() {\n\t\treturn `${(this._oUDate as UniversalDate).sCalendarType}: ${this.getYear()}/${this.getMonth() + 1}/${this.getDate()}`;\n\t}\n\n\tvalueOf() {\n\t\treturn this._oUDate.getTime();\n\t}\n\n\tstatic fromLocalJSDate(oJSDate: Date | UI5Date, sCalendarType?: `${CalendarType}`) {\n\t\t// Cross frame check for a date should be performed here otherwise setDateValue would fail in OPA tests\n\t\t// because Date object in the test is different than the Date object in the application (due to the iframe).\n\t\t// We can use jQuery.type or this method:\n\t\tfunction isValidDate(date: Date | UI5Date) {\n\t\t\treturn date && Object.prototype.toString.call(date) === \"[object Date]\" && !isNaN(date as unknown as number); // eslint-disable-line\n\t\t}\n\t\tif (!isValidDate(oJSDate)) {\n\t\t\tthrow new Error(`Date parameter must be a JavaScript Date object: [${oJSDate as unknown as string}].`);\n\t\t}\n\t\treturn new CalendarDate(oJSDate.getFullYear(), oJSDate.getMonth(), oJSDate.getDate(), sCalendarType);\n\t}\n\n\tstatic fromTimestamp(iTimestamp: number, sCalendarType?: `${CalendarType}`) {\n\t\tconst oCalDate = new CalendarDate(0, 0, 1);\n\t\tlet oUDate;\n\t\ttry {\n\t\t\toUDate = UniversalDate.getInstance(UI5Date.getInstance(iTimestamp), sCalendarType);\n\t\t} catch (e) {\n\t\t\toUDate = new Date(NaN); // UniversalDate.getInstance may now throw an Exception - keep the old behavior\n\t\t}\n\t\toCalDate._oUDate = oUDate;\n\t\treturn oCalDate;\n\t}\n}\n\nfunction createUniversalUTCDate(oDate: UI5Date | Date, sCalendarType: `${CalendarType}`) {\n\tif (sCalendarType) {\n\t\treturn UniversalDate.getInstance(createUTCDate(oDate), sCalendarType);\n\t}\n\treturn new UniversalDate(createUTCDate(oDate).getTime());\n}\n\n/**\n * Creates a JavaScript UTC Date corresponding to the given JavaScript Date.\n * @param {Date} oDate JavaScript date object. Time related information is cut.\n * @returns {Date} JavaScript date created from the date object, but this time considered as UTC date information.\n */\nfunction createUTCDate(oDate: UI5Date | Date) {\n\tconst oUTCDate = new Date(Date.UTC(0, 0, 1)); // no need to replace with UI5Date as we are creating a new UTC date object\n\n\toUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());\n\n\treturn oUTCDate;\n}\n\nfunction checkCalendarDate(oCalendarDate: CalendarDate) {\n\tif (!(oCalendarDate instanceof CalendarDate)) {\n\t\tthrow new Error(`Invalid calendar date: [${oCalendarDate as unknown as string}]. Expected: CalendarDate`);\n\t}\n}\n\n/**\n * Verifies the given value is numeric like, i.e. 3, \"3\" and throws an error if it is not.\n * @param {any} value The value of any type to check. If null or undefined, this method throws an error.\n * @param {string} message The message to be used if an error is to be thrown\n * @throws will throw an error if the value is null or undefined or is not like a number\n */\nfunction checkNumericLike(value: any, message: string) {\n\tif (value === undefined || value === Infinity || isNaN(value)) { // eslint-disable-line\n\t\tthrow message;\n\t}\n}\n\nexport default CalendarDate;\n"]}
@@ -0,0 +1,5 @@
1
+ import CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
+ import CalendarDate from "./CalendarDate.js";
3
+ declare const getMinCalendarDate: (primaryCalendarType: `${CalendarType}`) => CalendarDate;
4
+ declare const getMaxCalendarDate: (primaryCalendarType: `${CalendarType}`) => CalendarDate;
5
+ export { getMinCalendarDate, getMaxCalendarDate, };