@ui5/webcomponents-localization 0.0.0-dff5837d7 → 0.0.0-e818f286e

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 (119) hide show
  1. package/.eslintignore +1 -0
  2. package/CHANGELOG.md +220 -0
  3. package/README.md +36 -6
  4. package/dist/Assets-static.js +2 -0
  5. package/dist/dates/CalendarDate.js +29 -3
  6. package/dist/dates/ExtremeDates.js +39 -0
  7. package/dist/dates/convertMonthNumbersToMonthNames.js +33 -0
  8. package/dist/dates/getDaysInMonth.js +11 -0
  9. package/dist/dates/getRoundedTimestamp.js +14 -0
  10. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  11. package/dist/dates/modifyDateBy.js +42 -0
  12. package/dist/dates/transformDateToSecondaryType.js +20 -0
  13. package/dist/generated/assets/cldr/ar.json +5 -3
  14. package/dist/generated/assets/cldr/ar_EG.json +5 -3
  15. package/dist/generated/assets/cldr/ar_SA.json +5 -3
  16. package/dist/generated/assets/cldr/bg.json +5 -3
  17. package/dist/generated/assets/cldr/ca.json +5 -3
  18. package/dist/generated/assets/cldr/cs.json +5 -3
  19. package/dist/generated/assets/cldr/cy.json +5886 -0
  20. package/dist/generated/assets/cldr/da.json +5 -3
  21. package/dist/generated/assets/cldr/de.json +5 -3
  22. package/dist/generated/assets/cldr/de_AT.json +5 -3
  23. package/dist/generated/assets/cldr/de_CH.json +5 -3
  24. package/dist/generated/assets/cldr/el.json +5 -3
  25. package/dist/generated/assets/cldr/el_CY.json +5 -3
  26. package/dist/generated/assets/cldr/en.json +6 -3
  27. package/dist/generated/assets/cldr/en_AU.json +6 -4
  28. package/dist/generated/assets/cldr/en_GB.json +5 -3
  29. package/dist/generated/assets/cldr/en_HK.json +5 -3
  30. package/dist/generated/assets/cldr/en_IE.json +5 -3
  31. package/dist/generated/assets/cldr/en_IN.json +5 -3
  32. package/dist/generated/assets/cldr/en_NZ.json +5 -3
  33. package/dist/generated/assets/cldr/en_PG.json +5 -3
  34. package/dist/generated/assets/cldr/en_SG.json +5 -3
  35. package/dist/generated/assets/cldr/en_ZA.json +5 -3
  36. package/dist/generated/assets/cldr/es.json +5 -3
  37. package/dist/generated/assets/cldr/es_AR.json +5 -3
  38. package/dist/generated/assets/cldr/es_BO.json +5 -3
  39. package/dist/generated/assets/cldr/es_CL.json +5 -3
  40. package/dist/generated/assets/cldr/es_CO.json +5 -3
  41. package/dist/generated/assets/cldr/es_MX.json +5 -3
  42. package/dist/generated/assets/cldr/es_PE.json +5 -3
  43. package/dist/generated/assets/cldr/es_UY.json +5 -3
  44. package/dist/generated/assets/cldr/es_VE.json +5 -3
  45. package/dist/generated/assets/cldr/et.json +5 -3
  46. package/dist/generated/assets/cldr/fa.json +5 -3
  47. package/dist/generated/assets/cldr/fi.json +5 -3
  48. package/dist/generated/assets/cldr/fr.json +5 -3
  49. package/dist/generated/assets/cldr/fr_BE.json +5 -3
  50. package/dist/generated/assets/cldr/fr_CA.json +5 -3
  51. package/dist/generated/assets/cldr/fr_CH.json +5 -3
  52. package/dist/generated/assets/cldr/fr_LU.json +5 -3
  53. package/dist/generated/assets/cldr/he.json +5 -3
  54. package/dist/generated/assets/cldr/hi.json +5 -3
  55. package/dist/generated/assets/cldr/hr.json +5 -3
  56. package/dist/generated/assets/cldr/hu.json +5 -3
  57. package/dist/generated/assets/cldr/id.json +5 -3
  58. package/dist/generated/assets/cldr/it.json +5 -3
  59. package/dist/generated/assets/cldr/it_CH.json +5 -3
  60. package/dist/generated/assets/cldr/ja.json +5 -3
  61. package/dist/generated/assets/cldr/kk.json +5 -3
  62. package/dist/generated/assets/cldr/ko.json +5 -3
  63. package/dist/generated/assets/cldr/lt.json +5 -3
  64. package/dist/generated/assets/cldr/lv.json +5 -3
  65. package/dist/generated/assets/cldr/ms.json +5 -3
  66. package/dist/generated/assets/cldr/nb.json +5 -3
  67. package/dist/generated/assets/cldr/nl.json +5 -3
  68. package/dist/generated/assets/cldr/nl_BE.json +5 -3
  69. package/dist/generated/assets/cldr/pl.json +5 -3
  70. package/dist/generated/assets/cldr/pt.json +5 -3
  71. package/dist/generated/assets/cldr/pt_PT.json +5 -3
  72. package/dist/generated/assets/cldr/ro.json +5 -3
  73. package/dist/generated/assets/cldr/ru.json +5 -3
  74. package/dist/generated/assets/cldr/ru_UA.json +5 -3
  75. package/dist/generated/assets/cldr/sk.json +5 -3
  76. package/dist/generated/assets/cldr/sl.json +5 -3
  77. package/dist/generated/assets/cldr/sr.json +5 -3
  78. package/dist/generated/assets/cldr/sr_Latn.json +5129 -0
  79. package/dist/generated/assets/cldr/sv.json +5 -3
  80. package/dist/generated/assets/cldr/th.json +5 -3
  81. package/dist/generated/assets/cldr/tr.json +5 -3
  82. package/dist/generated/assets/cldr/uk.json +5 -3
  83. package/dist/generated/assets/cldr/vi.json +5 -3
  84. package/dist/generated/assets/cldr/zh_CN.json +5 -3
  85. package/dist/generated/assets/cldr/zh_HK.json +5 -3
  86. package/dist/generated/assets/cldr/zh_SG.json +5 -3
  87. package/dist/generated/assets/cldr/zh_TW.json +5 -3
  88. package/dist/generated/json-imports/LocaleData-static.js +90 -0
  89. package/dist/generated/json-imports/LocaleData.js +88 -91
  90. package/dist/getCachedLocaleDataInstance.js +13 -0
  91. package/dist/sap/base/Log.js +2 -10
  92. package/dist/sap/base/assert.js +1 -5
  93. package/dist/sap/base/util/LoaderExtensions.js +12 -2
  94. package/dist/sap/base/util/array/uniqueSort.js +7 -7
  95. package/dist/sap/base/util/deepEqual.js +1 -5
  96. package/dist/sap/ui/base/Interface.js +3 -5
  97. package/dist/sap/ui/base/Metadata.js +1 -3
  98. package/dist/sap/ui/base/Object.js +26 -2
  99. package/dist/sap/ui/core/Core.js +2 -0
  100. package/dist/sap/ui/core/Locale.js +67 -31
  101. package/dist/sap/ui/core/LocaleData.js +56 -1504
  102. package/dist/sap/ui/core/date/UniversalDate.js +13 -5
  103. package/dist/sap/ui/core/format/DateFormat.js +402 -194
  104. package/dist/sap/ui/core/format/TimezoneUtil.js +83 -0
  105. package/package-scripts.js +10 -6
  106. package/package.json +12 -14
  107. package/src/Assets-static.js +2 -0
  108. package/src/dates/CalendarDate.js +29 -3
  109. package/src/dates/ExtremeDates.js +39 -0
  110. package/src/dates/convertMonthNumbersToMonthNames.js +33 -0
  111. package/src/dates/getDaysInMonth.js +11 -0
  112. package/src/dates/getRoundedTimestamp.js +14 -0
  113. package/src/dates/getTodayUTCTimestamp.js +9 -0
  114. package/src/dates/modifyDateBy.js +42 -0
  115. package/src/dates/transformDateToSecondaryType.js +20 -0
  116. package/src/getCachedLocaleDataInstance.js +13 -0
  117. package/src/sap/base/util/LoaderExtensions.js +12 -2
  118. package/src/sap/ui/core/Core.js +2 -0
  119. package/used-modules.txt +1 -0
package/.eslintignore CHANGED
@@ -2,3 +2,4 @@ dist
2
2
  lib
3
3
  overlay
4
4
  package-scripts.js
5
+ .eslintrc.js
package/CHANGELOG.md CHANGED
@@ -3,6 +3,226 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.6.0](https://github.com/SAP/ui5-webcomponents/compare/v1.5.0...v1.6.0) (2022-07-25)
7
+
8
+
9
+ ### Features
10
+
11
+ * **ui5-calendar:** show months and years from both primary and secon… ([#5412](https://github.com/SAP/ui5-webcomponents/issues/5412)) ([d5dc7ec](https://github.com/SAP/ui5-webcomponents/commit/d5dc7ec))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.5.0](https://github.com/SAP/ui5-webcomponents/compare/v1.4.0...v1.5.0) (2022-07-03)
18
+
19
+ **Note:** Version bump only for package @ui5/webcomponents-localization
20
+
21
+
22
+
23
+
24
+
25
+ # [1.4.0](https://github.com/SAP/ui5-webcomponents/compare/v1.3.1...v1.4.0) (2022-05-25)
26
+
27
+ **Note:** Version bump only for package @ui5/webcomponents-localization
28
+
29
+
30
+
31
+
32
+
33
+ ## [1.3.1](https://github.com/SAP/ui5-webcomponents/compare/v1.3.0...v1.3.1) (2022-04-27)
34
+
35
+ **Note:** Version bump only for package @ui5/webcomponents-localization
36
+
37
+
38
+
39
+
40
+
41
+ # [1.3.0](https://github.com/SAP/ui5-webcomponents/compare/v1.2.4...v1.3.0) (2022-04-19)
42
+
43
+
44
+ ### Bug Fixes
45
+
46
+ * **localization:** fix js error if "sh" locale set ([#4905](https://github.com/SAP/ui5-webcomponents/issues/4905)) ([979bca2](https://github.com/SAP/ui5-webcomponents/commit/979bca2)), closes [#4904](https://github.com/SAP/ui5-webcomponents/issues/4904)
47
+
48
+
49
+
50
+
51
+
52
+ ## [1.2.4](https://github.com/SAP/ui5-webcomponents/compare/v1.2.3...v1.2.4) (2022-03-30)
53
+
54
+ **Note:** Version bump only for package @ui5/webcomponents-localization
55
+
56
+
57
+
58
+
59
+
60
+ ## [1.2.3](https://github.com/SAP/ui5-webcomponents/compare/v1.2.2...v1.2.3) (2022-03-23)
61
+
62
+ **Note:** Version bump only for package @ui5/webcomponents-localization
63
+
64
+
65
+
66
+
67
+
68
+ ## [1.2.2](https://github.com/SAP/ui5-webcomponents/compare/v1.2.1...v1.2.2) (2022-03-22)
69
+
70
+
71
+ ### Bug Fixes
72
+
73
+ * **localization:** fix js error if "sh" locale set ([#4905](https://github.com/SAP/ui5-webcomponents/issues/4905)) ([9ace82c](https://github.com/SAP/ui5-webcomponents/commit/9ace82c)), closes [#4904](https://github.com/SAP/ui5-webcomponents/issues/4904)
74
+
75
+
76
+
77
+
78
+
79
+
80
+ ## [1.2.1](https://github.com/SAP/ui5-webcomponents/compare/v1.2.0...v1.2.1) (2022-03-02)
81
+
82
+ **Note:** Version bump only for package @ui5/webcomponents-localization
83
+
84
+
85
+
86
+
87
+
88
+ # [1.2.0](https://github.com/SAP/ui5-webcomponents/compare/v1.1.2...v1.2.0) (2022-02-28)
89
+
90
+ **Note:** Version bump only for package @ui5/webcomponents-localization
91
+
92
+
93
+
94
+
95
+
96
+ ## [1.1.2](https://github.com/SAP/ui5-webcomponents/compare/v1.1.1...v1.1.2) (2022-01-26)
97
+
98
+ **Note:** Version bump only for package @ui5/webcomponents-localization
99
+
100
+
101
+
102
+
103
+
104
+ ## [1.1.1](https://github.com/SAP/ui5-webcomponents/compare/v1.1.0...v1.1.1) (2022-01-24)
105
+
106
+ **Note:** Version bump only for package @ui5/webcomponents-localization
107
+
108
+
109
+
110
+
111
+
112
+ # [1.1.0](https://github.com/SAP/ui5-webcomponents/compare/v1.0.2...v1.1.0) (2022-01-21)
113
+
114
+ **Note:** Version bump only for package @ui5/webcomponents-localization
115
+
116
+
117
+
118
+
119
+
120
+ ## [1.0.2](https://github.com/SAP/ui5-webcomponents/compare/v1.0.1...v1.0.2) (2021-11-29)
121
+
122
+ **Note:** Version bump only for package @ui5/webcomponents-localization
123
+
124
+
125
+
126
+
127
+
128
+ ## [1.0.1](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0...v1.0.1) (2021-11-10)
129
+
130
+ **Note:** Version bump only for package @ui5/webcomponents-localization
131
+
132
+
133
+
134
+
135
+
136
+ # [1.0.0](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.16...v1.0.0) (2021-11-10)
137
+
138
+
139
+ **Note:** Version bump only for package @ui5/webcomponents-localization
140
+
141
+
142
+
143
+
144
+
145
+ # [1.0.0-rc.16](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.15...v1.0.0-rc.16) (2021-11-09)
146
+
147
+
148
+ **Note:** Version bump only for package @ui5/webcomponents-localization
149
+
150
+
151
+
152
+
153
+
154
+ # [1.0.0-rc.15](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.14...v1.0.0-rc.15) (2021-07-23)
155
+
156
+
157
+ **Note:** Version bump only for package @ui5/webcomponents-icons-tnt
158
+
159
+
160
+
161
+
162
+ # [1.0.0-rc.14](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.13...v1.0.0-rc.14) (2021-04-01)
163
+
164
+
165
+
166
+
167
+
168
+ # [1.0.0-rc.13](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.12...v1.0.0-rc.13) (2021-03-26)
169
+
170
+
171
+
172
+
173
+ **Note:** Version bump only for package @ui5/webcomponents-localization
174
+
175
+
176
+
177
+
178
+
179
+ # [1.0.0-rc.12](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.11...v1.0.0-rc.12) (2021-02-18)
180
+
181
+
182
+ ### Bug Fixes
183
+
184
+ * **ui5-calendar:** Today date is now timezone aware ([#2660](https://github.com/SAP/ui5-webcomponents/issues/2660)) ([32dd0ef](https://github.com/SAP/ui5-webcomponents/commit/32dd0ef))
185
+
186
+
187
+
188
+
189
+ # [1.0.0-rc.11](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.10...v1.0.0-rc.11) (2020-12-21)
190
+
191
+ **Note:** Version bump only for package @ui5/webcomponents-localization
192
+
193
+
194
+
195
+
196
+
197
+ # [1.0.0-rc.10](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.9...v1.0.0-rc.10) (2020-11-12)
198
+
199
+
200
+ **Note:** Version bump only for package @ui5/webcomponents-localization
201
+
202
+
203
+
204
+
205
+
206
+ # [1.0.0-rc.9](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.8...v1.0.0-rc.9) (2020-10-08)
207
+
208
+
209
+ ### Features
210
+
211
+ **Note:** Version bump only for package @ui5/webcomponents-localization
212
+
213
+
214
+
215
+
216
+
217
+ # [1.0.0-rc.8](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.7...v1.0.0-rc.8) (2020-07-30)
218
+
219
+
220
+ **Note:** Version bump only for package @ui5/webcomponents-localization
221
+
222
+
223
+
224
+
225
+
6
226
  # [1.0.0-rc.7](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.6...v1.0.0-rc.7) (2020-04-30)
7
227
 
8
228
  **Note:** Version bump only for package @ui5/webcomponents-localization
package/README.md CHANGED
@@ -1,23 +1,53 @@
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
  # UI5 Web Components - Localization
4
4
 
5
- [![Travis CI Build Status](https://travis-ci.org/SAP/ui5-webcomponents.svg?branch=master)](https://travis-ci.org/SAP/ui5-webcomponents)
6
5
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)
7
6
 
8
7
  Provides date/time and CLDR functionality for the purposes of building UI5 Web Components.
9
8
 
9
+ ## Provided assets
10
+
11
+ The assets, provided by this package, are CLDR data:
12
+
13
+ `import "@ui5/webcomponents-localization/dist/Assets.js";`
14
+
15
+ *Note:* These assets are already imported by the UI5 Web Components packages that need them.
16
+
17
+ ## Provided features
18
+
19
+ | Feature Import | Description |
20
+ |----------------------------------------------------------------------|---------------------------|
21
+ | `@ui5/webcomponents-localization/dist/features/calendar/Buddhist.js` | Buddhist calendar support |
22
+ | `@ui5/webcomponents-localization/dist/features/calendar/Islamic.js` | Islamic calendar support |
23
+ | `@ui5/webcomponents-localization/dist/features/calendar/Japanese.js` | Japanese calendar support |
24
+ | `@ui5/webcomponents-localization/dist/features/calendar/Persian.js` | Persian calendar support |
25
+
26
+ ### Advanced Calendar Types Feature
27
+
28
+ ```js
29
+ import "@ui5/webcomponents-localization/dist/features/calendar/Buddhist.js";
30
+ import "@ui5/webcomponents-localization/dist/features/calendar/Islamic.js";
31
+ import "@ui5/webcomponents-localization/dist/features/calendar/Japanese.js";
32
+ import "@ui5/webcomponents-localization/dist/features/calendar/Persian.js";
33
+ ```
34
+
35
+ The `ui5-date-picker` and `ui5-datetime-picker` components supports Gregorian Calendar by default.
36
+
37
+ In order to be able to use Buddhist, Islamic, Japanese, or Persian calendar with these components
38
+ (by setting its `primaryCalendarType` property), you must import one or more of the modules above.
39
+
10
40
  ## Resources
11
- - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/master/README.md)
41
+ - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
12
42
  - [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
13
43
  - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
14
44
 
15
45
  ## 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/).
46
+ 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
47
 
18
48
  ## Contribute
19
- Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/CONTRIBUTING.md).
49
+ Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).
20
50
 
21
51
  ## License
22
52
  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.
53
+ 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,2 @@
1
+ // Currently the base package provides CLDR assets only
2
+ import "./generated/json-imports/LocaleData-static.js";
@@ -64,9 +64,29 @@ class CalendarDate {
64
64
  return this._oUDate.getUTCMonth();
65
65
  }
66
66
 
67
- setMonth(month) {
67
+ /**
68
+ * Sets the given month as ordinal month of the year.
69
+ * @param {int} month An integer between 0 and 11, representing the months January through December( or their
70
+ * equivalent month names for the given calendar).
71
+ * If the specified value is is outside of the expected range, this method attempts to update the date information
72
+ * accordingly. For example, if 12 is given as a month, the year will be incremented by 1, and 1 will be used for month.
73
+ * @param {int} [date] An integer between 1 and 31, representing the day of the month, but other values are allowed.
74
+ * 0 will result in the previous month's last day.
75
+ * -1 will result in the day before the previous month's last day.
76
+ * 32 will result in:
77
+ * - first day of the next month if the current month has 31 days.
78
+ * - second day of the next month if the current month has 30 days.
79
+ * Other value will result in adding or subtracting days according to the given value.
80
+ * @returns {sap.ui.unified.calendar.CalendarDate} <code>this</code> for method chaining.
81
+ */
82
+ setMonth(month, date) {
68
83
  checkNumericLike(month, `Invalid month: ${month}`);
69
- this._oUDate.setUTCMonth(month);
84
+ if (date || date === 0) {
85
+ checkNumericLike(date, `Invalid date: ${date}`);
86
+ this._oUDate.setUTCMonth(month, date);
87
+ } else {
88
+ this._oUDate.setUTCMonth(month);
89
+ }
70
90
  return this;
71
91
  }
72
92
 
@@ -157,7 +177,13 @@ class CalendarDate {
157
177
 
158
178
  static fromTimestamp(iTimestamp, sCalendarType) {
159
179
  const oCalDate = new CalendarDate(0, 0, 1);
160
- oCalDate._oUDate = UniversalDate.getInstance(new Date(iTimestamp), sCalendarType);
180
+ let oUDate;
181
+ try {
182
+ oUDate = UniversalDate.getInstance(new Date(iTimestamp), sCalendarType);
183
+ } catch (e) {
184
+ oUDate = new Date(NaN); // UniversalDate.getInstance may now throw an Exception - keep the old behavior
185
+ }
186
+ oCalDate._oUDate = oUDate;
161
187
  return oCalDate;
162
188
  }
163
189
  }
@@ -0,0 +1,39 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+
3
+ const cache = new Map();
4
+
5
+ const getMinCalendarDate = primaryCalendarType => {
6
+ const key = `min ${primaryCalendarType}`;
7
+
8
+ if (!cache.has(key)) {
9
+ const minDate = new CalendarDate(1, 0, 1, primaryCalendarType);
10
+ minDate.setYear(1);
11
+ minDate.setMonth(0);
12
+ minDate.setDate(1);
13
+ cache.set(key, minDate);
14
+ }
15
+
16
+ return cache.get(key);
17
+ };
18
+
19
+ const getMaxCalendarDate = primaryCalendarType => {
20
+ const key = `max ${primaryCalendarType}`;
21
+
22
+ if (!cache.has(key)) {
23
+ const maxDate = new CalendarDate(1, 0, 1, primaryCalendarType);
24
+ maxDate.setYear(9999);
25
+ maxDate.setMonth(11);
26
+ const tempDate = new CalendarDate(maxDate, primaryCalendarType);
27
+ tempDate.setDate(1);
28
+ tempDate.setMonth(tempDate.getMonth() + 1, 0);
29
+ maxDate.setDate(tempDate.getDate());// 31st for Gregorian Calendar
30
+ cache.set(key, maxDate);
31
+ }
32
+
33
+ return cache.get(key);
34
+ };
35
+
36
+ export {
37
+ getMinCalendarDate,
38
+ getMaxCalendarDate,
39
+ };
@@ -0,0 +1,33 @@
1
+ import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
2
+ import getCachedLocaleDataInstance from "../getCachedLocaleDataInstance.js";
3
+
4
+ /**
5
+ * Convert month number to month name (text).
6
+ * If the numbers of the two months are the same you will get the name of the month,
7
+ * otherwise you will get the two names separated by a dash
8
+ *
9
+ * @param firstMonth CalendarDate Month
10
+ * @param lastMonth CalendarDate Month
11
+ * @param calendarType calendar type
12
+ * @returns {String}
13
+ */
14
+ const convertMonthNumbersToMonthNames = (firstMonth, lastMonth, calendarType) => {
15
+ const localeData = getCachedLocaleDataInstance(getLocale());
16
+ const pattern = localeData.getIntervalPattern();
17
+ const secondaryMonthsNames = localeData.getMonthsStandAlone("abbreviated", calendarType);
18
+ const secondaryMonthsNamesWide = localeData.getMonthsStandAlone("wide", calendarType);
19
+
20
+ if (firstMonth === lastMonth) {
21
+ return {
22
+ text: localeData.getMonths("abbreviated", calendarType)[firstMonth],
23
+ textInfo: localeData.getMonths("wide", calendarType)[firstMonth],
24
+ };
25
+ }
26
+
27
+ return {
28
+ text: pattern.replace(/\{0\}/, secondaryMonthsNames[firstMonth]).replace(/\{1\}/, secondaryMonthsNames[lastMonth]),
29
+ textInfo: pattern.replace(/\{0\}/, secondaryMonthsNamesWide[firstMonth]).replace(/\{1\}/, secondaryMonthsNamesWide[lastMonth]),
30
+ };
31
+ };
32
+
33
+ export default convertMonthNumbersToMonthNames;
@@ -0,0 +1,11 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+
3
+ const getDaysInMonth = date => {
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;
@@ -0,0 +1,14 @@
1
+ /**
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}
5
+ */
6
+ const getRoundedTimestamp = millisecondsUTC => {
7
+ if (!millisecondsUTC) {
8
+ millisecondsUTC = new Date().getTime();
9
+ }
10
+ const rounded = millisecondsUTC - (millisecondsUTC % (24 * 60 * 60 * 1000));
11
+ return rounded / 1000;
12
+ };
13
+
14
+ export default getRoundedTimestamp;
@@ -0,0 +1,9 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+
3
+ /**
4
+ * Returns a UTC timestamp representing today
5
+ * @public
6
+ */
7
+ const getTodayUTCTimestamp = primaryCalendarType => CalendarDate.fromLocalJSDate(new Date(), primaryCalendarType).valueOf() / 1000;
8
+
9
+ export default getTodayUTCTimestamp;
@@ -0,0 +1,42 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+
3
+ /**
4
+ * Adds or subtracts a given amount of days/months/years from a date.
5
+ * If minDate or maxDate are given, the result will be enforced within these limits
6
+ *
7
+ * @param date CalendarDate instance
8
+ * @param amount how many days/months/years to add (can be a negative number)
9
+ * @param unit what to modify: "day", "month" or "year"
10
+ * @param minDate minimum date to enforce
11
+ * @param maxDate maximum date to enforce
12
+ */
13
+ const modifyDateBy = (date, amount, unit, minDate = null, maxDate = null) => {
14
+ const newDate = new CalendarDate(date);
15
+ if (unit === "day") {
16
+ newDate.setDate(date.getDate() + amount);
17
+ } else if (unit === "month") {
18
+ newDate.setMonth(date.getMonth() + amount);
19
+ const stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month
20
+ const monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month
21
+ if (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios
22
+ newDate.setDate(0);
23
+ }
24
+ } else {
25
+ newDate.setYear(date.getYear() + amount);
26
+ if (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year
27
+ newDate.setDate(0); // Select the last day of the month
28
+ }
29
+ }
30
+
31
+ if (minDate && newDate.valueOf() < minDate.valueOf()) {
32
+ return new CalendarDate(minDate);
33
+ }
34
+
35
+ if (maxDate && newDate.valueOf() > maxDate.valueOf()) {
36
+ return new CalendarDate(maxDate);
37
+ }
38
+
39
+ return newDate;
40
+ };
41
+
42
+ export default modifyDateBy;
@@ -0,0 +1,20 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+ import getDaysInMonth from "./getDaysInMonth.js";
3
+
4
+ const transformDateToSecondaryType = (primaryCalendarType, secondaryCalendarType, timeStamp, hasYearPicker) => {
5
+ let firstDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);
6
+ let lastDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);
7
+ firstDate.setDate(1);
8
+
9
+ if (hasYearPicker) {
10
+ firstDate.setMonth(0);
11
+ lastDate.setMonth(11);
12
+ }
13
+
14
+ lastDate.setDate(getDaysInMonth(lastDate));
15
+ firstDate = new CalendarDate(firstDate, secondaryCalendarType);
16
+ lastDate = new CalendarDate(lastDate, secondaryCalendarType);
17
+ return { firstDate, lastDate };
18
+ };
19
+
20
+ export default transformDateToSecondaryType;
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "__license": "This file has been derived from Unicode Common Locale Data Repository (CLDR) files (http://cldr.unicode.org). See the copyright and permission notice in the Unicode-Data-Files-LICENSE.txt available at the same location as this file or visit http://www.unicode.org/copyright.html",
3
+ "__version": "35.1.0",
4
+ "__buildtime": "2020-10-20T05:15:22.539Z",
3
5
  "languages": {
4
6
  "aa": "الأفارية",
5
7
  "ab": "الأبخازية",
@@ -864,7 +866,7 @@
864
866
  "GU": "غوام",
865
867
  "GW": "غينيا بيساو",
866
868
  "GY": "غيانا",
867
- "HK": "هونج كونج، الصين",
869
+ "HK": "هونج كونج",
868
870
  "HK-alt-short": "هونغ كونغ",
869
871
  "HM": "جزيرة هيرد وجزر ماكدونالد",
870
872
  "HN": "هندوراس",
@@ -920,7 +922,7 @@
920
922
  "ML": "مالي",
921
923
  "MM": "ميانمار (بورما)",
922
924
  "MN": "منغوليا",
923
- "MO": "ماكاو، الصين",
925
+ "MO": "ماكاو",
924
926
  "MO-alt-short": "مكاو",
925
927
  "MP": "جزر ماريانا الشمالية",
926
928
  "MQ": "جزر المارتينيك",
@@ -1006,7 +1008,7 @@
1006
1008
  "TR": "تركيا",
1007
1009
  "TT": "ترينيداد وتوباغو",
1008
1010
  "TV": "توفالو",
1009
- "TW": "تايوان، الصين",
1011
+ "TW": "تايوان",
1010
1012
  "TZ": "تنزانيا",
1011
1013
  "UA": "أوكرانيا",
1012
1014
  "UG": "أوغندا",
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "__license": "This file has been derived from Unicode Common Locale Data Repository (CLDR) files (http://cldr.unicode.org). See the copyright and permission notice in the Unicode-Data-Files-LICENSE.txt available at the same location as this file or visit http://www.unicode.org/copyright.html",
3
+ "__version": "35.1.0",
4
+ "__buildtime": "2020-10-20T05:15:22.539Z",
3
5
  "languages": {
4
6
  "aa": "الأفارية",
5
7
  "ab": "الأبخازية",
@@ -864,7 +866,7 @@
864
866
  "GU": "غوام",
865
867
  "GW": "غينيا بيساو",
866
868
  "GY": "غيانا",
867
- "HK": "هونج كونج، الصين",
869
+ "HK": "هونج كونج",
868
870
  "HK-alt-short": "هونغ كونغ",
869
871
  "HM": "جزيرة هيرد وجزر ماكدونالد",
870
872
  "HN": "هندوراس",
@@ -920,7 +922,7 @@
920
922
  "ML": "مالي",
921
923
  "MM": "ميانمار (بورما)",
922
924
  "MN": "منغوليا",
923
- "MO": "ماكاو، الصين",
925
+ "MO": "ماكاو",
924
926
  "MO-alt-short": "مكاو",
925
927
  "MP": "جزر ماريانا الشمالية",
926
928
  "MQ": "جزر المارتينيك",
@@ -1006,7 +1008,7 @@
1006
1008
  "TR": "تركيا",
1007
1009
  "TT": "ترينيداد وتوباغو",
1008
1010
  "TV": "توفالو",
1009
- "TW": "تايوان، الصين",
1011
+ "TW": "تايوان",
1010
1012
  "TZ": "تنزانيا",
1011
1013
  "UA": "أوكرانيا",
1012
1014
  "UG": "أوغندا",
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "__license": "This file has been derived from Unicode Common Locale Data Repository (CLDR) files (http://cldr.unicode.org). See the copyright and permission notice in the Unicode-Data-Files-LICENSE.txt available at the same location as this file or visit http://www.unicode.org/copyright.html",
3
+ "__version": "35.1.0",
4
+ "__buildtime": "2020-10-20T05:15:22.539Z",
3
5
  "languages": {
4
6
  "aa": "الأفارية",
5
7
  "ab": "الأبخازية",
@@ -864,7 +866,7 @@
864
866
  "GU": "غوام",
865
867
  "GW": "غينيا بيساو",
866
868
  "GY": "غيانا",
867
- "HK": "هونج كونج، الصين",
869
+ "HK": "هونج كونج",
868
870
  "HK-alt-short": "هونغ كونغ",
869
871
  "HM": "جزيرة هيرد وجزر ماكدونالد",
870
872
  "HN": "هندوراس",
@@ -920,7 +922,7 @@
920
922
  "ML": "مالي",
921
923
  "MM": "ميانمار (بورما)",
922
924
  "MN": "منغوليا",
923
- "MO": "ماكاو، الصين",
925
+ "MO": "ماكاو",
924
926
  "MO-alt-short": "ماكاو",
925
927
  "MP": "جزر ماريانا الشمالية",
926
928
  "MQ": "جزر المارتينيك",
@@ -1006,7 +1008,7 @@
1006
1008
  "TR": "تركيا",
1007
1009
  "TT": "ترينيداد وتوباغو",
1008
1010
  "TV": "توفالو",
1009
- "TW": "تايوان، الصين",
1011
+ "TW": "تايوان",
1010
1012
  "TZ": "تنزانيا",
1011
1013
  "UA": "أوكرانيا",
1012
1014
  "UG": "أوغندا",
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "__license": "This file has been derived from Unicode Common Locale Data Repository (CLDR) files (http://cldr.unicode.org). See the copyright and permission notice in the Unicode-Data-Files-LICENSE.txt available at the same location as this file or visit http://www.unicode.org/copyright.html",
3
+ "__version": "35.1.0",
4
+ "__buildtime": "2020-10-20T05:15:22.539Z",
3
5
  "languages": {
4
6
  "aa": "афарски",
5
7
  "ab": "абхазки",
@@ -844,7 +846,7 @@
844
846
  "GU": "Гуам",
845
847
  "GW": "Гвинея-Бисау",
846
848
  "GY": "Гаяна",
847
- "HK": "Хонконг, Китай",
849
+ "HK": "Хонконг",
848
850
  "HK-alt-short": "Хонконг",
849
851
  "HM": "острови Хърд и Макдоналд",
850
852
  "HN": "Хондурас",
@@ -900,7 +902,7 @@
900
902
  "ML": "Мали",
901
903
  "MM": "Мианмар (Бирма)",
902
904
  "MN": "Монголия",
903
- "MO": "Макао, Китай",
905
+ "MO": "Макао",
904
906
  "MO-alt-short": "Макао",
905
907
  "MP": "Северни Мариански острови",
906
908
  "MQ": "Мартиника",
@@ -986,7 +988,7 @@
986
988
  "TR": "Турция",
987
989
  "TT": "Тринидад и Тобаго",
988
990
  "TV": "Тувалу",
989
- "TW": "Тайван, Китай",
991
+ "TW": "Тайван",
990
992
  "TZ": "Танзания",
991
993
  "UA": "Украйна",
992
994
  "UG": "Уганда",