@ui5/webcomponents-localization 0.0.0-a8e886a07 → 0.0.0-acc6fea96

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 (232) hide show
  1. package/.eslintignore +2 -1
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +1365 -0
  4. package/README.md +3 -5
  5. package/dist/.tsbuildinfo +1 -0
  6. package/dist/Assets-fetch.d.ts +1 -0
  7. package/dist/Assets-fetch.js +3 -0
  8. package/dist/Assets-fetch.js.map +1 -0
  9. package/dist/Assets.js.map +1 -1
  10. package/dist/CalendarUtils.d.ts +3 -0
  11. package/dist/CalendarUtils.js +6 -0
  12. package/dist/CalendarUtils.js.map +1 -0
  13. package/dist/DateFormat.d.ts +0 -1
  14. package/dist/DateFormat.js.map +1 -1
  15. package/dist/LocaleData.d.ts +0 -1
  16. package/dist/LocaleData.js.map +1 -1
  17. package/dist/dates/CalendarDate.d.ts +6 -5
  18. package/dist/dates/CalendarDate.js +8 -7
  19. package/dist/dates/CalendarDate.js.map +1 -1
  20. package/dist/dates/ExtremeDates.d.ts +3 -3
  21. package/dist/dates/ExtremeDates.js.map +1 -1
  22. package/dist/dates/UI5Date.d.ts +5 -0
  23. package/dist/dates/UI5Date.js +7 -0
  24. package/dist/dates/UI5Date.js.map +1 -0
  25. package/dist/dates/UniversalDate.d.ts +2 -1
  26. package/dist/dates/UniversalDate.js.map +1 -1
  27. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +1 -1
  28. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -1
  29. package/dist/dates/getDaysInMonth.js.map +1 -1
  30. package/dist/dates/getRoundedTimestamp.js +1 -0
  31. package/dist/dates/getRoundedTimestamp.js.map +1 -1
  32. package/dist/dates/getTodayUTCTimestamp.d.ts +1 -1
  33. package/dist/dates/getTodayUTCTimestamp.js +2 -1
  34. package/dist/dates/getTodayUTCTimestamp.js.map +1 -1
  35. package/dist/dates/modifyDateBy.d.ts +2 -1
  36. package/dist/dates/modifyDateBy.js +34 -19
  37. package/dist/dates/modifyDateBy.js.map +1 -1
  38. package/dist/dates/transformDateToSecondaryType.d.ts +1 -1
  39. package/dist/dates/transformDateToSecondaryType.js +3 -2
  40. package/dist/dates/transformDateToSecondaryType.js.map +1 -1
  41. package/dist/features/calendar/Buddhist.js.map +1 -1
  42. package/dist/features/calendar/Gregorian.js.map +1 -1
  43. package/dist/features/calendar/Islamic.js.map +1 -1
  44. package/dist/features/calendar/Japanese.js.map +1 -1
  45. package/dist/features/calendar/Persian.js.map +1 -1
  46. package/dist/generated/assets/cldr/Unicode-Data-Files-LICENSE.txt +27 -0
  47. package/dist/generated/assets/cldr/ar.json +908 -527
  48. package/dist/generated/assets/cldr/ar_EG.json +908 -527
  49. package/dist/generated/assets/cldr/ar_SA.json +1003 -623
  50. package/dist/generated/assets/cldr/bg.json +902 -665
  51. package/dist/generated/assets/cldr/ca.json +845 -557
  52. package/dist/generated/assets/cldr/cnr.json +6169 -0
  53. package/dist/generated/assets/cldr/cs.json +823 -410
  54. package/dist/generated/assets/cldr/cy.json +964 -646
  55. package/dist/generated/assets/cldr/da.json +818 -544
  56. package/dist/generated/assets/cldr/de.json +710 -377
  57. package/dist/generated/assets/cldr/de_AT.json +700 -367
  58. package/dist/generated/assets/cldr/de_CH.json +719 -386
  59. package/dist/generated/assets/cldr/el.json +548 -297
  60. package/dist/generated/assets/cldr/el_CY.json +548 -297
  61. package/dist/generated/assets/cldr/en.json +861 -551
  62. package/dist/generated/assets/cldr/en_AU.json +1006 -648
  63. package/dist/generated/assets/cldr/en_GB.json +870 -530
  64. package/dist/generated/assets/cldr/en_HK.json +963 -620
  65. package/dist/generated/assets/cldr/en_IE.json +928 -588
  66. package/dist/generated/assets/cldr/en_IN.json +911 -567
  67. package/dist/generated/assets/cldr/en_NZ.json +947 -607
  68. package/dist/generated/assets/cldr/en_PG.json +948 -608
  69. package/dist/generated/assets/cldr/en_SG.json +937 -594
  70. package/dist/generated/assets/cldr/en_ZA.json +925 -585
  71. package/dist/generated/assets/cldr/es.json +1171 -711
  72. package/dist/generated/assets/cldr/es_AR.json +1114 -653
  73. package/dist/generated/assets/cldr/es_BO.json +1156 -695
  74. package/dist/generated/assets/cldr/es_CL.json +997 -644
  75. package/dist/generated/assets/cldr/es_CO.json +916 -562
  76. package/dist/generated/assets/cldr/es_MX.json +1325 -864
  77. package/dist/generated/assets/cldr/es_PE.json +841 -596
  78. package/dist/generated/assets/cldr/es_UY.json +869 -624
  79. package/dist/generated/assets/cldr/es_VE.json +888 -643
  80. package/dist/generated/assets/cldr/et.json +664 -368
  81. package/dist/generated/assets/cldr/fa.json +791 -490
  82. package/dist/generated/assets/cldr/fi.json +733 -344
  83. package/dist/generated/assets/cldr/fr.json +687 -433
  84. package/dist/generated/assets/cldr/fr_BE.json +684 -430
  85. package/dist/generated/assets/cldr/fr_CA.json +810 -556
  86. package/dist/generated/assets/cldr/fr_CH.json +627 -373
  87. package/dist/generated/assets/cldr/fr_LU.json +687 -433
  88. package/dist/generated/assets/cldr/he.json +909 -545
  89. package/dist/generated/assets/cldr/hi.json +493 -194
  90. package/dist/generated/assets/cldr/hr.json +1009 -496
  91. package/dist/generated/assets/cldr/hu.json +562 -305
  92. package/dist/generated/assets/cldr/id.json +880 -572
  93. package/dist/generated/assets/cldr/it.json +738 -466
  94. package/dist/generated/assets/cldr/it_CH.json +738 -466
  95. package/dist/generated/assets/cldr/ja.json +349 -88
  96. package/dist/generated/assets/cldr/kk.json +1033 -583
  97. package/dist/generated/assets/cldr/ko.json +407 -173
  98. package/dist/generated/assets/cldr/lt.json +621 -288
  99. package/dist/generated/assets/cldr/lv.json +613 -375
  100. package/dist/generated/assets/cldr/mk.json +6045 -0
  101. package/dist/generated/assets/cldr/ms.json +869 -552
  102. package/dist/generated/assets/cldr/nb.json +529 -236
  103. package/dist/generated/assets/cldr/nl.json +1019 -432
  104. package/dist/generated/assets/cldr/nl_BE.json +1019 -432
  105. package/dist/generated/assets/cldr/pl.json +1107 -492
  106. package/dist/generated/assets/cldr/pt.json +1171 -625
  107. package/dist/generated/assets/cldr/pt_PT.json +1112 -636
  108. package/dist/generated/assets/cldr/ro.json +835 -489
  109. package/dist/generated/assets/cldr/ru.json +850 -518
  110. package/dist/generated/assets/cldr/ru_UA.json +844 -512
  111. package/dist/generated/assets/cldr/sk.json +833 -569
  112. package/dist/generated/assets/cldr/sl.json +741 -435
  113. package/dist/generated/assets/cldr/sr.json +700 -349
  114. package/dist/generated/assets/cldr/sr_Latn.json +1329 -994
  115. package/dist/generated/assets/cldr/sv.json +746 -446
  116. package/dist/generated/assets/cldr/th.json +484 -238
  117. package/dist/generated/assets/cldr/tr.json +721 -438
  118. package/dist/generated/assets/cldr/uk.json +884 -547
  119. package/dist/generated/assets/cldr/vi.json +662 -430
  120. package/dist/generated/assets/cldr/zh_CN.json +631 -345
  121. package/dist/generated/assets/cldr/zh_HK.json +602 -315
  122. package/dist/generated/assets/cldr/zh_SG.json +607 -320
  123. package/dist/generated/assets/cldr/zh_TW.json +459 -193
  124. package/dist/generated/json-imports/LocaleData-fetch.d.ts +1 -0
  125. package/dist/generated/json-imports/LocaleData-fetch.js +93 -0
  126. package/dist/generated/json-imports/LocaleData-fetch.js.map +1 -0
  127. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  128. package/dist/generated/json-imports/LocaleData.js +89 -89
  129. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  130. package/dist/getCachedLocaleDataInstance.js.map +1 -1
  131. package/dist/locale/getLocaleData.js.map +1 -1
  132. package/dist/sap/base/Event.js +59 -0
  133. package/dist/sap/base/Eventing.js +146 -0
  134. package/dist/sap/base/Log.js +2 -239
  135. package/dist/sap/base/assert.js +28 -1
  136. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  137. package/dist/sap/base/config.js +17 -0
  138. package/dist/sap/base/i18n/Formatting.d.ts +8 -0
  139. package/dist/sap/base/i18n/Formatting.js +11 -0
  140. package/dist/sap/base/i18n/Formatting.js.map +1 -0
  141. package/dist/sap/base/i18n/LanguageTag.js +173 -0
  142. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  143. package/dist/sap/base/i18n/Localization.js +12 -0
  144. package/dist/sap/base/i18n/Localization.js.map +1 -0
  145. package/dist/sap/base/i18n/date/CalendarType.js +43 -0
  146. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +105 -0
  147. package/dist/sap/base/i18n/date/TimezoneUtils.js +319 -0
  148. package/dist/sap/base/strings/camelize.js +30 -0
  149. package/dist/sap/base/strings/formatMessage.js +88 -15
  150. package/dist/sap/base/util/LoaderExtensions.js.map +1 -1
  151. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  152. package/dist/sap/base/util/ObjectPath.js +4 -33
  153. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  154. package/dist/sap/base/util/Version.js +157 -0
  155. package/dist/sap/base/util/_merge.js +83 -26
  156. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  157. package/dist/sap/base/util/deepClone.js +102 -0
  158. package/dist/sap/base/util/deepEqual.js +75 -51
  159. package/dist/sap/base/util/extend.js +58 -7
  160. package/dist/sap/base/util/isEmptyObject.js +34 -0
  161. package/dist/sap/base/util/isPlainObject.js +35 -1
  162. package/dist/sap/base/util/now.js +24 -3
  163. package/dist/sap/base/util/resolveReference.js +3 -0
  164. package/dist/sap/base/util/uid.js +27 -0
  165. package/dist/sap/ui/base/DataType.js +657 -0
  166. package/dist/sap/ui/base/Interface.js +47 -1
  167. package/dist/sap/ui/base/Metadata.js +435 -171
  168. package/dist/sap/ui/base/Object.js +284 -48
  169. package/dist/sap/ui/core/CalendarType.js +24 -8
  170. package/dist/sap/ui/core/Configuration.d.ts +2 -2
  171. package/dist/sap/ui/core/Configuration.js +4 -1
  172. package/dist/sap/ui/core/Configuration.js.map +1 -1
  173. package/dist/sap/ui/core/Core.d.ts +3 -4
  174. package/dist/sap/ui/core/Core.js.map +1 -1
  175. package/dist/sap/ui/core/FormatSettings.d.ts +1 -2
  176. package/dist/sap/ui/core/FormatSettings.js +0 -1
  177. package/dist/sap/ui/core/FormatSettings.js.map +1 -1
  178. package/dist/sap/ui/core/Locale.js +190 -155
  179. package/dist/sap/ui/core/LocaleData.js +2662 -1300
  180. package/dist/sap/ui/core/Supportability.js +5 -0
  181. package/dist/sap/ui/core/Theming.js +539 -0
  182. package/dist/sap/ui/core/date/Buddhist.js +162 -87
  183. package/dist/sap/ui/core/date/CalendarUtils.js +61 -32
  184. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -7
  185. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  186. package/dist/sap/ui/core/date/Islamic.js +298 -185
  187. package/dist/sap/ui/core/date/Japanese.js +210 -115
  188. package/dist/sap/ui/core/date/Persian.js +324 -195
  189. package/dist/sap/ui/core/date/UI5Date.js +991 -0
  190. package/dist/sap/ui/core/date/UniversalDate.js +1238 -255
  191. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  192. package/dist/sap/ui/core/format/DateFormat.js +3167 -2093
  193. package/dist/sap/ui/core/format/TimezoneUtil.js +24 -94
  194. package/package-scripts.cjs +28 -0
  195. package/package.json +14 -7
  196. package/tsconfig.json +20 -9
  197. package/used-modules.txt +24 -1
  198. package/dist/Assets-static.d.ts +0 -1
  199. package/dist/Assets-static.js +0 -3
  200. package/dist/Assets-static.js.map +0 -1
  201. package/dist/dates/calculateWeekNumber.d.ts +0 -4
  202. package/dist/dates/calculateWeekNumber.js +0 -45
  203. package/dist/dates/calculateWeekNumber.js.map +0 -1
  204. package/dist/generated/json-imports/LocaleData-static.js +0 -90
  205. package/dist/sap/ui/Device.js +0 -5
  206. package/package-scripts.js +0 -38
  207. package/src/Assets-static.ts +0 -2
  208. package/src/Assets.ts +0 -2
  209. package/src/DateFormat.ts +0 -8
  210. package/src/LocaleData.ts +0 -8
  211. package/src/dates/CalendarDate.ts +0 -232
  212. package/src/dates/ExtremeDates.ts +0 -40
  213. package/src/dates/UniversalDate.ts +0 -51
  214. package/src/dates/calculateWeekNumber.ts +0 -53
  215. package/src/dates/convertMonthNumbersToMonthNames.ts +0 -34
  216. package/src/dates/getDaysInMonth.ts +0 -11
  217. package/src/dates/getRoundedTimestamp.ts +0 -14
  218. package/src/dates/getTodayUTCTimestamp.ts +0 -10
  219. package/src/dates/modifyDateBy.ts +0 -42
  220. package/src/dates/transformDateToSecondaryType.ts +0 -21
  221. package/src/features/calendar/Buddhist.ts +0 -1
  222. package/src/features/calendar/Gregorian.ts +0 -1
  223. package/src/features/calendar/Islamic.ts +0 -1
  224. package/src/features/calendar/Japanese.ts +0 -1
  225. package/src/features/calendar/Persian.ts +0 -1
  226. package/src/getCachedLocaleDataInstance.ts +0 -15
  227. package/src/locale/getLocaleData.ts +0 -28
  228. package/src/sap/base/util/LoaderExtensions.ts +0 -17
  229. package/src/sap/ui/core/Configuration.ts +0 -22
  230. package/src/sap/ui/core/Core.ts +0 -15
  231. package/src/sap/ui/core/FormatSettings.ts +0 -15
  232. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -1,232 +0,0 @@
1
- import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
- import UniversalDate from "./UniversalDate.js";
3
-
4
- class CalendarDate {
5
- _oUDate!: Date | UniversalDate;
6
-
7
- constructor(year?: number | CalendarDate, month?: number | string, date?: number, calendarType?: string) { // eslint-disable-line
8
- let aArgs = arguments, // eslint-disable-line
9
- oJSDate: Date,
10
- oNow: Date,
11
- sCalendarType!: CalendarType;
12
-
13
- switch (aArgs.length) {
14
- case 0: // defaults to the current date
15
- oNow = new Date();
16
- return (this.constructor(oNow.getFullYear(), oNow.getMonth(), oNow.getDate()) as CalendarDate);
17
-
18
- case 1: // CalendarDate
19
- case 2: // CalendarDate, sCalendarType
20
- if (!(aArgs[0] instanceof CalendarDate)) {
21
- throw new Error("Invalid arguments: the first argument must be of type CalendarDate.");
22
- }
23
- sCalendarType = aArgs[1] ? aArgs[1] : (aArgs[0]._oUDate as UniversalDate).sCalendarType;
24
- // Use source.valueOf() (returns the same point of time regardless calendar type) instead of
25
- // source's getters to avoid non-gregorian Year, Month and Date may be used to construct a Gregorian date
26
- oJSDate = new Date(aArgs[0].valueOf());
27
-
28
- // Make this date really local. Now getters are safe.
29
- oJSDate.setFullYear(oJSDate.getUTCFullYear(), oJSDate.getUTCMonth(), oJSDate.getUTCDate());
30
- oJSDate.setHours(oJSDate.getUTCHours(), oJSDate.getUTCMinutes(), oJSDate.getUTCSeconds(), oJSDate.getUTCMilliseconds());
31
-
32
- this._oUDate = createUniversalUTCDate(oJSDate, sCalendarType);
33
- break;
34
-
35
- case 3: // year, month, date
36
- case 4: // year, month, date, sCalendarType
37
- checkNumericLike(aArgs[0] as number, `Invalid year: ${aArgs[0] as number}`);
38
- checkNumericLike(aArgs[1] as number, `Invalid month: ${aArgs[1] as number}`);
39
- checkNumericLike(aArgs[2] as number, `Invalid date: ${aArgs[2] as number}`);
40
-
41
- oJSDate = new Date(0, 0, 1);
42
- oJSDate.setFullYear(aArgs[0] as number, aArgs[1] as number, aArgs[2] as number); // 2 digits year is not supported. If so, it is considered as full year as well.
43
-
44
- if (aArgs[3]) {
45
- sCalendarType = aArgs[3];
46
- }
47
- this._oUDate = createUniversalUTCDate(oJSDate, sCalendarType);
48
- break;
49
-
50
- default:
51
- throw new Error(`${"Invalid arguments. Accepted arguments are: 1) oCalendarDate, (optional)calendarType"
52
- + "or 2) year, month, date, (optional) calendarType"}${aArgs as unknown as string}`);
53
- }
54
- }
55
-
56
- getYear() {
57
- return this._oUDate.getUTCFullYear();
58
- }
59
-
60
- setYear(year: number) {
61
- checkNumericLike(year, `Invalid year: ${year}`);
62
- this._oUDate.setUTCFullYear(year);
63
- return this;
64
- }
65
-
66
- getMonth() {
67
- return this._oUDate.getUTCMonth();
68
- }
69
-
70
- /**
71
- * Sets the given month as ordinal month of the year.
72
- * @param {int} month An integer between 0 and 11, representing the months January through December( or their
73
- * equivalent month names for the given calendar).
74
- * If the specified value is is outside of the expected range, this method attempts to update the date information
75
- * accordingly. For example, if 12 is given as a month, the year will be incremented by 1, and 1 will be used for month.
76
- * @param {int} [date] An integer between 1 and 31, representing the day of the month, but other values are allowed.
77
- * 0 will result in the previous month's last day.
78
- * -1 will result in the day before the previous month's last day.
79
- * 32 will result in:
80
- * - first day of the next month if the current month has 31 days.
81
- * - second day of the next month if the current month has 30 days.
82
- * Other value will result in adding or subtracting days according to the given value.
83
- * @returns {sap.ui.unified.calendar.CalendarDate} <code>this</code> for method chaining.
84
- */
85
- setMonth(month: number, date?: number) {
86
- checkNumericLike(month, `Invalid month: ${month}`);
87
- if (date || date === 0) {
88
- checkNumericLike(date, `Invalid date: ${date}`);
89
- this._oUDate.setUTCMonth(month, date);
90
- } else {
91
- this._oUDate.setUTCMonth(month);
92
- }
93
- return this;
94
- }
95
-
96
- getDate() {
97
- return this._oUDate.getUTCDate();
98
- }
99
-
100
- setDate(date: number) {
101
- checkNumericLike(date, `Invalid date: ${date}`);
102
- this._oUDate.setUTCDate(date);
103
- return this;
104
- }
105
-
106
- getDay() {
107
- return this._oUDate.getUTCDay();
108
- }
109
-
110
- getCalendarType() {
111
- return (this._oUDate as UniversalDate).sCalendarType;
112
- }
113
-
114
- isBefore(oCalendarDate: CalendarDate) {
115
- checkCalendarDate(oCalendarDate);
116
- return this.valueOf() < oCalendarDate.valueOf();
117
- }
118
-
119
- isAfter(oCalendarDate: CalendarDate) {
120
- checkCalendarDate(oCalendarDate);
121
- return this.valueOf() > oCalendarDate.valueOf();
122
- }
123
-
124
- isSameOrBefore(oCalendarDate: CalendarDate) {
125
- checkCalendarDate(oCalendarDate);
126
- return this.valueOf() <= oCalendarDate.valueOf();
127
- }
128
-
129
- isSameOrAfter(oCalendarDate: CalendarDate) {
130
- checkCalendarDate(oCalendarDate);
131
- return this.valueOf() >= oCalendarDate.valueOf();
132
- }
133
-
134
- isSame(oCalendarDate: CalendarDate) {
135
- checkCalendarDate(oCalendarDate);
136
- return this.valueOf() === oCalendarDate.valueOf();
137
- }
138
-
139
- toLocalJSDate() {
140
- // Use this._oUDate.getTime()(returns the same point of time regardless calendar type) instead of
141
- // this._oUDate's getters to avoid non-gregorian Year, Month and Date to be used to construct a Gregorian date
142
- const oLocalDate = new Date(this._oUDate.getTime());
143
-
144
- // Make this date really local. Now getters are safe.
145
- oLocalDate.setFullYear(oLocalDate.getUTCFullYear(), oLocalDate.getUTCMonth(), oLocalDate.getUTCDate());
146
- oLocalDate.setHours(0, 0, 0, 0);
147
-
148
- return oLocalDate;
149
- }
150
-
151
- toUTCJSDate() {
152
- // Use this._oUDate.getTime()(returns the same point of time regardless calendar type) instead of
153
- // this._oUDate's getters to avoid non-gregorian Year, Month and Date to be used to construct a Gregorian date
154
- const oUTCDate = new Date(this._oUDate.getTime());
155
- oUTCDate.setUTCHours(0, 0, 0, 0);
156
-
157
- return oUTCDate;
158
- }
159
-
160
- toString() {
161
- return `${(this._oUDate as UniversalDate).sCalendarType}: ${this.getYear()}/${this.getMonth() + 1}/${this.getDate()}`;
162
- }
163
-
164
- valueOf() {
165
- return this._oUDate.getTime();
166
- }
167
-
168
- static fromLocalJSDate(oJSDate: Date, sCalendarType?: CalendarType) {
169
- // Cross frame check for a date should be performed here otherwise setDateValue would fail in OPA tests
170
- // because Date object in the test is different than the Date object in the application (due to the iframe).
171
- // We can use jQuery.type or this method:
172
- function isValidDate(date: Date) {
173
- return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date as unknown as number); // eslint-disable-line
174
- }
175
- if (!isValidDate(oJSDate)) {
176
- throw new Error(`Date parameter must be a JavaScript Date object: [${oJSDate as unknown as string}].`);
177
- }
178
- return new CalendarDate(oJSDate.getFullYear(), oJSDate.getMonth(), oJSDate.getDate(), sCalendarType);
179
- }
180
-
181
- static fromTimestamp(iTimestamp: number, sCalendarType?: CalendarType) {
182
- const oCalDate = new CalendarDate(0, 0, 1);
183
- let oUDate;
184
- try {
185
- oUDate = UniversalDate.getInstance(new Date(iTimestamp), sCalendarType);
186
- } catch (e) {
187
- oUDate = new Date(NaN); // UniversalDate.getInstance may now throw an Exception - keep the old behavior
188
- }
189
- oCalDate._oUDate = oUDate;
190
- return oCalDate;
191
- }
192
- }
193
-
194
- function createUniversalUTCDate(oDate: Date, sCalendarType: CalendarType) {
195
- if (sCalendarType) {
196
- return UniversalDate.getInstance(createUTCDate(oDate), sCalendarType);
197
- }
198
- return new UniversalDate(createUTCDate(oDate).getTime());
199
- }
200
-
201
- /**
202
- * Creates a JavaScript UTC Date corresponding to the given JavaScript Date.
203
- * @param {Date} oDate JavaScript date object. Time related information is cut.
204
- * @returns {Date} JavaScript date created from the date object, but this time considered as UTC date information.
205
- */
206
- function createUTCDate(oDate: Date) {
207
- const oUTCDate = new Date(Date.UTC(0, 0, 1));
208
-
209
- oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
210
-
211
- return oUTCDate;
212
- }
213
-
214
- function checkCalendarDate(oCalendarDate: CalendarDate) {
215
- if (!(oCalendarDate instanceof CalendarDate)) {
216
- throw new Error(`Invalid calendar date: [${oCalendarDate as unknown as string}]. Expected: CalendarDate`);
217
- }
218
- }
219
-
220
- /**
221
- * Verifies the given value is numeric like, i.e. 3, "3" and throws an error if it is not.
222
- * @param {any} value The value of any type to check. If null or undefined, this method throws an error.
223
- * @param {string} message The message to be used if an error is to be thrown
224
- * @throws will throw an error if the value is null or undefined or is not like a number
225
- */
226
- function checkNumericLike(value: any, message: string) {
227
- if (value === undefined || value === Infinity || isNaN(value)) { // eslint-disable-line
228
- throw message;
229
- }
230
- }
231
-
232
- export default CalendarDate;
@@ -1,40 +0,0 @@
1
- import CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
- import CalendarDate from "./CalendarDate.js";
3
-
4
- const cache = new Map<string, CalendarDate>();
5
-
6
- const getMinCalendarDate = (primaryCalendarType: CalendarType) => {
7
- const key = `min ${primaryCalendarType}`;
8
-
9
- if (!cache.has(key)) {
10
- const minDate = new CalendarDate(1, 0, 1, primaryCalendarType);
11
- minDate.setYear(1);
12
- minDate.setMonth(0);
13
- minDate.setDate(1);
14
- cache.set(key, minDate);
15
- }
16
-
17
- return cache.get(key)!;
18
- };
19
-
20
- const getMaxCalendarDate = (primaryCalendarType: CalendarType) => {
21
- const key = `max ${primaryCalendarType}`;
22
-
23
- if (!cache.has(key)) {
24
- const maxDate = new CalendarDate(1, 0, 1, primaryCalendarType);
25
- maxDate.setYear(9999);
26
- maxDate.setMonth(11);
27
- const tempDate = new CalendarDate(maxDate, primaryCalendarType);
28
- tempDate.setDate(1);
29
- tempDate.setMonth(tempDate.getMonth() + 1, 0);
30
- maxDate.setDate(tempDate.getDate());// 31st for Gregorian Calendar
31
- cache.set(key, maxDate);
32
- }
33
-
34
- return cache.get(key)!;
35
- };
36
-
37
- export {
38
- getMinCalendarDate,
39
- getMaxCalendarDate,
40
- };
@@ -1,51 +0,0 @@
1
- import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
- // @ts-ignore
3
- import UniversalDateNative from "../sap/ui/core/date/UniversalDate.js";
4
-
5
- type UniversalDate = {
6
- new (time: number): UniversalDate;
7
- oDate: Date,
8
- sCalendarType: string,
9
- getInstance: (oDate: Date, sCalendarType?: CalendarType) => UniversalDate,
10
- getDate: () => number,
11
- getMonth: () => number,
12
- getFullYear: () => number,
13
- getYear: () => number,
14
- getDay: () => number,
15
- getHours: () => number,
16
- getMinutes: () => number,
17
- getSeconds: () => number,
18
- getMilliseconds: () => number,
19
- getUTCDate: () => number,
20
- getUTCMonth: () => number,
21
- getUTCFullYear: () => number,
22
- getUTCDay: () => number,
23
- getUTCHours: () => number,
24
- getUTCMinutes: () => number,
25
- getUTCSeconds: () => number,
26
- getUTCMilliseconds: () => number,
27
- getTime: () => number,
28
- valueOf: () => number,
29
- getTimezoneOffset: () => number,
30
- toString: () => string,
31
- toDateString: () => string,
32
- setDate: (dayValue: number) => number,
33
- setFullYear: (yearValue: number, monthValue?: number, dateValue?: number) => number,
34
- setYear: (yearValue: number) => number,
35
- setMonth: (monthValue: number, dayValue?: number) => number,
36
- setHours: (hoursValue: number, minutesValue?: number, secondsValue?: number, msValue?: number) => number,
37
- setMinutes: (minutesValue: number, secondsValue?: number, msValue?: number) => number,
38
- setSeconds: (secondsValue: number, msValue?: number) => number,
39
- setMilliseconds: (setMilliseconds: number) => number,
40
- setUTCDate:(dayValue: number) => number,
41
- setUTCFullYear: (yearValue: number, monthValue?: number, dayValue?: number) => number,
42
- setUTCMonth: (monthValue: number, dayValue?: number) => number,
43
- setUTCHours: (hoursValue: number, minutesValue?: number, secondsValue?: number, msValue?: number) => number,
44
- setUTCMinutes: (minutesValue: number, secondsValue?: number, msValue?: number) => number,
45
- setUTCSeconds: (secondsValue: number, msValue?: number) => number,
46
- setUTCMilliseconds: (setMilliseconds: number) => number,
47
- }
48
-
49
- const UniversalDate: UniversalDate = UniversalDateNative;
50
-
51
- export default UniversalDate;
@@ -1,53 +0,0 @@
1
- import type Locale from "@ui5/webcomponents-base/dist/locale/Locale.js";
2
- import UniversalDate from "./UniversalDate.js";
3
- import type LocaleData from "../LocaleData.js";
4
-
5
- const calculateWeekNumber = (confFirstDayOfWeek: number | undefined, oDate: Date, iYear: number, oLocale: Locale, oLocaleData: LocaleData) => {
6
- let iWeekNum = 0;
7
- let iWeekDay = 0;
8
- const iFirstDayOfWeek = Number.isInteger(confFirstDayOfWeek) ? confFirstDayOfWeek! : oLocaleData.getFirstDayOfWeek();
9
-
10
- // search Locale for containing "en-US", since sometimes
11
- // when any user settings have been defined, subtag "sapufmt" is added to the locale name
12
- // this is described inside sap.ui.core.Configuration file
13
- if (oLocale && (oLocale.getLanguage() === "en" && oLocale.getRegion() === "US")) {
14
- /*
15
- * in US the week starts with Sunday
16
- * The first week of the year starts with January 1st. But Dec. 31 is still in the last year
17
- * So the week beginning in December and ending in January has 2 week numbers
18
- */
19
- const oJanFirst = new UniversalDate(oDate.getTime());
20
- oJanFirst.setUTCFullYear(iYear, 0, 1);
21
- iWeekDay = oJanFirst.getUTCDay();
22
-
23
- // get the date for the same weekday like jan 1.
24
- const oCheckDate = new UniversalDate(oDate.getTime());
25
- oCheckDate.setUTCDate(oCheckDate.getUTCDate() - oCheckDate.getUTCDay() + iWeekDay);
26
-
27
- iWeekNum = Math.round((oCheckDate.getTime() - oJanFirst.getTime()) / 86400000 / 7) + 1;
28
- } else {
29
- // normally the first week of the year is the one where the first Thursday of the year is
30
- // find Thursday of this week
31
- // if the checked day is before the 1. day of the week use a day of the previous week to check
32
- const oThursday = new UniversalDate(oDate.getTime());
33
- oThursday.setUTCDate(oThursday.getUTCDate() - iFirstDayOfWeek);
34
- iWeekDay = oThursday.getUTCDay();
35
- oThursday.setUTCDate(oThursday.getUTCDate() - iWeekDay + 4);
36
-
37
- const oFirstDayOfYear = new UniversalDate(oThursday.getTime());
38
- oFirstDayOfYear.setUTCMonth(0, 1);
39
- iWeekDay = oFirstDayOfYear.getUTCDay();
40
- let iAddDays = 0;
41
- if (iWeekDay > 4) {
42
- iAddDays = 7; // first day of year is after Thursday, so first Thursday is in the next week
43
- }
44
- const oFirstThursday = new UniversalDate(oFirstDayOfYear.getTime());
45
- oFirstThursday.setUTCDate(1 - iWeekDay + 4 + iAddDays);
46
-
47
- iWeekNum = Math.round((oThursday.getTime() - oFirstThursday.getTime()) / 86400000 / 7) + 1;
48
- }
49
-
50
- return iWeekNum;
51
- };
52
-
53
- export default calculateWeekNumber;
@@ -1,34 +0,0 @@
1
- import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
2
- import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
3
- import getCachedLocaleDataInstance from "../getCachedLocaleDataInstance.js";
4
-
5
- /**
6
- * Convert month number to month name (text).
7
- * If the numbers of the two months are the same you will get the name of the month,
8
- * otherwise you will get the two names separated by a dash
9
- *
10
- * @param firstMonth CalendarDate Month
11
- * @param lastMonth CalendarDate Month
12
- * @param calendarType calendar type
13
- * @returns {String}
14
- */
15
- const convertMonthNumbersToMonthNames = (firstMonth: number, lastMonth: number, calendarType?: CalendarType) => {
16
- const localeData = getCachedLocaleDataInstance(getLocale());
17
- const pattern = localeData.getIntervalPattern("");
18
- const secondaryMonthsNames = localeData.getMonthsStandAlone("abbreviated", calendarType) as Array<string>;
19
- const secondaryMonthsNamesWide = localeData.getMonthsStandAlone("wide", calendarType) as Array<string>;
20
-
21
- if (firstMonth === lastMonth) {
22
- return {
23
- text: localeData.getMonths("abbreviated", calendarType)[firstMonth],
24
- textInfo: localeData.getMonths("wide", calendarType)[firstMonth],
25
- };
26
- }
27
-
28
- return {
29
- text: pattern.replace(/\{0\}/, secondaryMonthsNames[firstMonth]).replace(/\{1\}/, secondaryMonthsNames[lastMonth]),
30
- textInfo: pattern.replace(/\{0\}/, secondaryMonthsNamesWide[firstMonth]).replace(/\{1\}/, secondaryMonthsNamesWide[lastMonth]),
31
- };
32
- };
33
-
34
- export default convertMonthNumbersToMonthNames;
@@ -1,11 +0,0 @@
1
- import CalendarDate from "./CalendarDate.js";
2
-
3
- const getDaysInMonth = (date: CalendarDate) => {
4
- const tempCalendarDate = new CalendarDate(date);
5
- tempCalendarDate.setDate(1);
6
- tempCalendarDate.setMonth(tempCalendarDate.getMonth() + 1);
7
- tempCalendarDate.setDate(0);
8
- return tempCalendarDate.getDate();
9
- };
10
-
11
- export default getDaysInMonth;
@@ -1,14 +0,0 @@
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 { number } millisecondsUTC
4
- * @returns { number }
5
- */
6
- const getRoundedTimestamp = (millisecondsUTC: number) => {
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;
@@ -1,10 +0,0 @@
1
- import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
- import CalendarDate from "./CalendarDate.js";
3
-
4
- /**
5
- * Returns a UTC timestamp representing today
6
- * @public
7
- */
8
- const getTodayUTCTimestamp = (primaryCalendarType: CalendarType) => CalendarDate.fromLocalJSDate(new Date(), primaryCalendarType).valueOf() / 1000;
9
-
10
- export default getTodayUTCTimestamp;
@@ -1,42 +0,0 @@
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: CalendarDate, amount: number, unit: string, minDate?: CalendarDate, maxDate?: CalendarDate) => {
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;
@@ -1,21 +0,0 @@
1
- import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
- import CalendarDate from "./CalendarDate.js";
3
- import getDaysInMonth from "./getDaysInMonth.js";
4
-
5
- const transformDateToSecondaryType = (primaryCalendarType: CalendarType | undefined, secondaryCalendarType: CalendarType| undefined, timeStamp: number, hasYearPicker?: boolean) => {
6
- let firstDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);
7
- let lastDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);
8
- firstDate.setDate(1);
9
-
10
- if (hasYearPicker) {
11
- firstDate.setMonth(0);
12
- lastDate.setMonth(11);
13
- }
14
-
15
- lastDate.setDate(getDaysInMonth(lastDate));
16
- firstDate = new CalendarDate(firstDate, secondaryCalendarType);
17
- lastDate = new CalendarDate(lastDate, secondaryCalendarType);
18
- return { firstDate, lastDate };
19
- };
20
-
21
- export default transformDateToSecondaryType;
@@ -1 +0,0 @@
1
- import "../../sap/ui/core/date/Buddhist.js";
@@ -1 +0,0 @@
1
- import "../../sap/ui/core/date/Gregorian.js";
@@ -1 +0,0 @@
1
- import "../../sap/ui/core/date/Islamic.js";
@@ -1 +0,0 @@
1
- import "../../sap/ui/core/date/Japanese.js";
@@ -1 +0,0 @@
1
- import "../../sap/ui/core/date/Persian.js";
@@ -1,15 +0,0 @@
1
- import type Locale from "@ui5/webcomponents-base/dist/locale/Locale.js";
2
- import type LocaleT from "sap/ui/core/Locale";
3
- import LocaleData from "./LocaleData.js";
4
-
5
- const cache = new Map<Locale, LocaleData>();
6
-
7
- const getCachedLocaleDataInstance = (locale: Locale) => {
8
- if (!cache.has(locale)) {
9
- cache.set(locale, new LocaleData(locale as unknown as LocaleT));
10
- }
11
-
12
- return cache.get(locale)!;
13
- };
14
-
15
- export default getCachedLocaleDataInstance;
@@ -1,28 +0,0 @@
1
- import { fetchCldr } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js";
2
- import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
3
- import type LocaleT from "sap/ui/core/Locale";
4
- import LocaleData from "../LocaleData.js";
5
-
6
- const instances = new Map<string, LocaleData>();
7
-
8
- /**
9
- * Fetches and returns а LocaleData object for the required locale
10
- * For more information on this object's API, please see:
11
- * https://sdk.openui5.org/api/sap.ui.core.LocaleData
12
- *
13
- * @param { string } lang - if left empty, will use the configured/current locale
14
- * @returns { Promise<LocaleData> }
15
- */
16
- const getLocaleData = async (lang: string): Promise<LocaleData> => {
17
- const locale = getLocale(lang);
18
- const localeLang = locale.getLanguage();
19
-
20
- if (!instances.has(localeLang)) {
21
- await fetchCldr(locale.getLanguage(), locale.getRegion(), locale.getScript());
22
- instances.set(localeLang, new LocaleData(locale as unknown as LocaleT));
23
- }
24
-
25
- return instances.get(localeLang)!;
26
- };
27
-
28
- export default getLocaleData;
@@ -1,17 +0,0 @@
1
- import { getLocaleData } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js";
2
-
3
- const loadResource = (moduleName: string) => {
4
- const moduleFormat = moduleName.match(/sap\/ui\/core\/cldr\/(\w+)\.json/);
5
- if (!moduleFormat) {
6
- throw new Error(`Unknown module "${moduleName}"`);
7
- }
8
-
9
- const localeId = moduleFormat[1];
10
- return getLocaleData(localeId);
11
- };
12
-
13
- const LoaderExtensions = {
14
- loadResource,
15
- };
16
-
17
- export default LoaderExtensions;
@@ -1,22 +0,0 @@
1
- import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
2
- import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
3
- import getDesigntimePropertyAsArray from "@ui5/webcomponents-base/dist/util/getDesigntimePropertyAsArray.js";
4
- // @ts-ignore
5
- import TimezoneUtil from "./format/TimezoneUtil.js";
6
- import FormatSettings from "./FormatSettings.js";
7
-
8
- const emptyFn = () => {};
9
-
10
- /**
11
- * OpenUI5 Configuration Shim
12
- */
13
- const Configuration = {
14
- getLanguage,
15
- getCalendarType,
16
- getSupportedLanguages: () => getDesigntimePropertyAsArray("$core-i18n-locales:,ar,bg,ca,cs,da,de,el,en,es,et,fi,fr,hi,hr,hu,it,iw,ja,ko,lt,lv,nl,no,pl,pt,ro,ru,sh,sk,sl,sv,th,tr,uk,vi,zh_CN,zh_TW$"),
17
- getOriginInfo: emptyFn,
18
- getFormatSettings: () => FormatSettings,
19
- getTimezone: () => TimezoneUtil.getLocalTimezone() as string,
20
- };
21
-
22
- export default Configuration;
@@ -1,15 +0,0 @@
1
- import FormatSettings from "./FormatSettings.js";
2
- import Configuration from "./Configuration.js";
3
-
4
- const emptyFn = () => {};
5
-
6
- /**
7
- * OpenUI5 Core shim
8
- */
9
- const Core = {
10
- getConfiguration: () => Configuration,
11
- getLibraryResourceBundle: emptyFn(),
12
- getFormatSettings: () => FormatSettings,
13
- };
14
-
15
- export default Core;
@@ -1,15 +0,0 @@
1
- import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
2
-
3
- const emptyFn = () => {};
4
-
5
- /**
6
- * OpenUI5 FormatSettings shim
7
- */
8
- const FormatSettings = {
9
- getFormatLocale: getLocale,
10
- getLegacyDateFormat: emptyFn,
11
- getLegacyDateCalendarCustomizing: emptyFn,
12
- getCustomLocaleData: emptyFn,
13
- };
14
-
15
- export default FormatSettings;
File without changes