@ui5/webcomponents-localization 0.0.0-037d08c67

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 (236) hide show
  1. package/.eslintignore +6 -0
  2. package/.eslintrc.cjs +3 -0
  3. package/.npsrc.json +3 -0
  4. package/CHANGELOG.md +2261 -0
  5. package/LICENSE.txt +201 -0
  6. package/README.md +51 -0
  7. package/dist/.tsbuildinfo +1 -0
  8. package/dist/Assets-fetch.d.ts +1 -0
  9. package/dist/Assets-fetch.js +3 -0
  10. package/dist/Assets-fetch.js.map +1 -0
  11. package/dist/Assets-node.d.ts +11 -0
  12. package/dist/Assets-node.js +12 -0
  13. package/dist/Assets-node.js.map +1 -0
  14. package/dist/Assets.d.ts +1 -0
  15. package/dist/Assets.js +3 -0
  16. package/dist/Assets.js.map +1 -0
  17. package/dist/CalendarUtils.d.ts +3 -0
  18. package/dist/CalendarUtils.js +6 -0
  19. package/dist/CalendarUtils.js.map +1 -0
  20. package/dist/DateFormat.d.ts +5 -0
  21. package/dist/DateFormat.js +7 -0
  22. package/dist/DateFormat.js.map +1 -0
  23. package/dist/LocaleData.d.ts +5 -0
  24. package/dist/LocaleData.js +7 -0
  25. package/dist/LocaleData.js.map +1 -0
  26. package/dist/NumberFormat.d.ts +5 -0
  27. package/dist/NumberFormat.js +7 -0
  28. package/dist/NumberFormat.js.map +1 -0
  29. package/dist/dates/CalendarDate.d.ts +42 -0
  30. package/dist/dates/CalendarDate.js +193 -0
  31. package/dist/dates/CalendarDate.js.map +1 -0
  32. package/dist/dates/ExtremeDates.d.ts +5 -0
  33. package/dist/dates/ExtremeDates.js +29 -0
  34. package/dist/dates/ExtremeDates.js.map +1 -0
  35. package/dist/dates/UI5Date.d.ts +5 -0
  36. package/dist/dates/UI5Date.js +7 -0
  37. package/dist/dates/UI5Date.js.map +1 -0
  38. package/dist/dates/UniversalDate.d.ts +47 -0
  39. package/dist/dates/UniversalDate.js +5 -0
  40. package/dist/dates/UniversalDate.js.map +1 -0
  41. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  42. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  43. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  44. package/dist/dates/getDaysInMonth.d.ts +3 -0
  45. package/dist/dates/getDaysInMonth.js +10 -0
  46. package/dist/dates/getDaysInMonth.js.map +1 -0
  47. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  48. package/dist/dates/getRoundedTimestamp.js +15 -0
  49. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  50. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  51. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  52. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  53. package/dist/dates/modifyDateBy.d.ts +14 -0
  54. package/dist/dates/modifyDateBy.js +55 -0
  55. package/dist/dates/modifyDateBy.js.map +1 -0
  56. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  57. package/dist/dates/transformDateToSecondaryType.js +18 -0
  58. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  59. package/dist/features/calendar/Buddhist.d.ts +1 -0
  60. package/dist/features/calendar/Buddhist.js +2 -0
  61. package/dist/features/calendar/Buddhist.js.map +1 -0
  62. package/dist/features/calendar/Gregorian.d.ts +1 -0
  63. package/dist/features/calendar/Gregorian.js +2 -0
  64. package/dist/features/calendar/Gregorian.js.map +1 -0
  65. package/dist/features/calendar/Islamic.d.ts +1 -0
  66. package/dist/features/calendar/Islamic.js +2 -0
  67. package/dist/features/calendar/Islamic.js.map +1 -0
  68. package/dist/features/calendar/Japanese.d.ts +1 -0
  69. package/dist/features/calendar/Japanese.js +2 -0
  70. package/dist/features/calendar/Japanese.js.map +1 -0
  71. package/dist/features/calendar/Persian.d.ts +1 -0
  72. package/dist/features/calendar/Persian.js +2 -0
  73. package/dist/features/calendar/Persian.js.map +1 -0
  74. package/dist/generated/assets/cldr/Unicode-Data-Files-LICENSE.txt +27 -0
  75. package/dist/generated/assets/cldr/ar.json +7087 -0
  76. package/dist/generated/assets/cldr/ar_EG.json +7087 -0
  77. package/dist/generated/assets/cldr/ar_SA.json +7086 -0
  78. package/dist/generated/assets/cldr/bg.json +5981 -0
  79. package/dist/generated/assets/cldr/ca.json +6083 -0
  80. package/dist/generated/assets/cldr/cnr.json +6169 -0
  81. package/dist/generated/assets/cldr/cs.json +6709 -0
  82. package/dist/generated/assets/cldr/cy.json +6932 -0
  83. package/dist/generated/assets/cldr/da.json +5927 -0
  84. package/dist/generated/assets/cldr/de.json +6048 -0
  85. package/dist/generated/assets/cldr/de_AT.json +6049 -0
  86. package/dist/generated/assets/cldr/de_CH.json +6047 -0
  87. package/dist/generated/assets/cldr/el.json +5832 -0
  88. package/dist/generated/assets/cldr/el_CY.json +5832 -0
  89. package/dist/generated/assets/cldr/en.json +6044 -0
  90. package/dist/generated/assets/cldr/en_AU.json +6084 -0
  91. package/dist/generated/assets/cldr/en_GB.json +6075 -0
  92. package/dist/generated/assets/cldr/en_HK.json +6084 -0
  93. package/dist/generated/assets/cldr/en_IE.json +6075 -0
  94. package/dist/generated/assets/cldr/en_IN.json +6080 -0
  95. package/dist/generated/assets/cldr/en_NZ.json +6075 -0
  96. package/dist/generated/assets/cldr/en_PG.json +6076 -0
  97. package/dist/generated/assets/cldr/en_SG.json +6080 -0
  98. package/dist/generated/assets/cldr/en_ZA.json +6076 -0
  99. package/dist/generated/assets/cldr/es.json +6103 -0
  100. package/dist/generated/assets/cldr/es_AR.json +6106 -0
  101. package/dist/generated/assets/cldr/es_BO.json +6105 -0
  102. package/dist/generated/assets/cldr/es_CL.json +5998 -0
  103. package/dist/generated/assets/cldr/es_CO.json +5998 -0
  104. package/dist/generated/assets/cldr/es_MX.json +6107 -0
  105. package/dist/generated/assets/cldr/es_PE.json +5889 -0
  106. package/dist/generated/assets/cldr/es_UY.json +5891 -0
  107. package/dist/generated/assets/cldr/es_VE.json +5890 -0
  108. package/dist/generated/assets/cldr/et.json +6027 -0
  109. package/dist/generated/assets/cldr/fa.json +5950 -0
  110. package/dist/generated/assets/cldr/fi.json +6195 -0
  111. package/dist/generated/assets/cldr/fr.json +5997 -0
  112. package/dist/generated/assets/cldr/fr_BE.json +5997 -0
  113. package/dist/generated/assets/cldr/fr_CA.json +5991 -0
  114. package/dist/generated/assets/cldr/fr_CH.json +6015 -0
  115. package/dist/generated/assets/cldr/fr_LU.json +5997 -0
  116. package/dist/generated/assets/cldr/he.json +6541 -0
  117. package/dist/generated/assets/cldr/hi.json +5859 -0
  118. package/dist/generated/assets/cldr/hr.json +6196 -0
  119. package/dist/generated/assets/cldr/hu.json +5945 -0
  120. package/dist/generated/assets/cldr/id.json +5730 -0
  121. package/dist/generated/assets/cldr/it.json +5986 -0
  122. package/dist/generated/assets/cldr/it_CH.json +5986 -0
  123. package/dist/generated/assets/cldr/ja.json +5889 -0
  124. package/dist/generated/assets/cldr/kk.json +5939 -0
  125. package/dist/generated/assets/cldr/ko.json +5770 -0
  126. package/dist/generated/assets/cldr/lt.json +6578 -0
  127. package/dist/generated/assets/cldr/lv.json +6114 -0
  128. package/dist/generated/assets/cldr/mk.json +6045 -0
  129. package/dist/generated/assets/cldr/ms.json +5564 -0
  130. package/dist/generated/assets/cldr/nb.json +6035 -0
  131. package/dist/generated/assets/cldr/nl.json +6202 -0
  132. package/dist/generated/assets/cldr/nl_BE.json +6202 -0
  133. package/dist/generated/assets/cldr/pl.json +6589 -0
  134. package/dist/generated/assets/cldr/pt.json +6115 -0
  135. package/dist/generated/assets/cldr/pt_PT.json +6180 -0
  136. package/dist/generated/assets/cldr/ro.json +6200 -0
  137. package/dist/generated/assets/cldr/ru.json +6503 -0
  138. package/dist/generated/assets/cldr/ru_UA.json +6503 -0
  139. package/dist/generated/assets/cldr/sk.json +6432 -0
  140. package/dist/generated/assets/cldr/sl.json +6444 -0
  141. package/dist/generated/assets/cldr/sr.json +6241 -0
  142. package/dist/generated/assets/cldr/sr_Latn.json +6226 -0
  143. package/dist/generated/assets/cldr/sv.json +6076 -0
  144. package/dist/generated/assets/cldr/th.json +5875 -0
  145. package/dist/generated/assets/cldr/tr.json +6094 -0
  146. package/dist/generated/assets/cldr/uk.json +6454 -0
  147. package/dist/generated/assets/cldr/vi.json +5669 -0
  148. package/dist/generated/assets/cldr/zh_CN.json +5717 -0
  149. package/dist/generated/assets/cldr/zh_HK.json +5726 -0
  150. package/dist/generated/assets/cldr/zh_SG.json +5726 -0
  151. package/dist/generated/assets/cldr/zh_TW.json +5793 -0
  152. package/dist/generated/json-imports/LocaleData-fetch.d.ts +1 -0
  153. package/dist/generated/json-imports/LocaleData-fetch.js +93 -0
  154. package/dist/generated/json-imports/LocaleData-fetch.js.map +1 -0
  155. package/dist/generated/json-imports/LocaleData-node.d.ts +1 -0
  156. package/dist/generated/json-imports/LocaleData-node.js +93 -0
  157. package/dist/generated/json-imports/LocaleData-node.js.map +1 -0
  158. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  159. package/dist/generated/json-imports/LocaleData.js +93 -0
  160. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  161. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  162. package/dist/getCachedLocaleDataInstance.js +10 -0
  163. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  164. package/dist/locale/getLocaleData.d.ts +11 -0
  165. package/dist/locale/getLocaleData.js +23 -0
  166. package/dist/locale/getLocaleData.js.map +1 -0
  167. package/dist/sap/base/Event.js +59 -0
  168. package/dist/sap/base/Eventing.js +146 -0
  169. package/dist/sap/base/Log.js +3 -0
  170. package/dist/sap/base/assert.js +34 -0
  171. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  172. package/dist/sap/base/config.js +17 -0
  173. package/dist/sap/base/i18n/Formatting.d.ts +8 -0
  174. package/dist/sap/base/i18n/Formatting.js +11 -0
  175. package/dist/sap/base/i18n/Formatting.js.map +1 -0
  176. package/dist/sap/base/i18n/LanguageTag.js +173 -0
  177. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  178. package/dist/sap/base/i18n/Localization.js +12 -0
  179. package/dist/sap/base/i18n/Localization.js.map +1 -0
  180. package/dist/sap/base/i18n/date/CalendarType.js +43 -0
  181. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +105 -0
  182. package/dist/sap/base/i18n/date/TimezoneUtils.js +319 -0
  183. package/dist/sap/base/strings/camelize.js +30 -0
  184. package/dist/sap/base/strings/formatMessage.js +93 -0
  185. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  186. package/dist/sap/base/util/LoaderExtensions.js +14 -0
  187. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  188. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  189. package/dist/sap/base/util/ObjectPath.js +6 -0
  190. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  191. package/dist/sap/base/util/Version.js +157 -0
  192. package/dist/sap/base/util/_merge.js +89 -0
  193. package/dist/sap/base/util/array/uniqueSort.js +41 -0
  194. package/dist/sap/base/util/deepClone.js +102 -0
  195. package/dist/sap/base/util/deepEqual.js +83 -0
  196. package/dist/sap/base/util/extend.js +61 -0
  197. package/dist/sap/base/util/isEmptyObject.js +34 -0
  198. package/dist/sap/base/util/isPlainObject.js +52 -0
  199. package/dist/sap/base/util/now.js +28 -0
  200. package/dist/sap/base/util/resolveReference.js +3 -0
  201. package/dist/sap/base/util/uid.js +27 -0
  202. package/dist/sap/ui/base/DataType.js +657 -0
  203. package/dist/sap/ui/base/Interface.js +72 -0
  204. package/dist/sap/ui/base/Metadata.js +483 -0
  205. package/dist/sap/ui/base/Object.js +300 -0
  206. package/dist/sap/ui/core/CalendarType.js +24 -0
  207. package/dist/sap/ui/core/Configuration.d.ts +17 -0
  208. package/dist/sap/ui/core/Configuration.js +23 -0
  209. package/dist/sap/ui/core/Configuration.js.map +1 -0
  210. package/dist/sap/ui/core/Core.d.ts +25 -0
  211. package/dist/sap/ui/core/Core.js +13 -0
  212. package/dist/sap/ui/core/Core.js.map +1 -0
  213. package/dist/sap/ui/core/FormatSettings.d.ts +9 -0
  214. package/dist/sap/ui/core/FormatSettings.js +12 -0
  215. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  216. package/dist/sap/ui/core/Locale.js +194 -0
  217. package/dist/sap/ui/core/LocaleData.js +2717 -0
  218. package/dist/sap/ui/core/Supportability.js +5 -0
  219. package/dist/sap/ui/core/Theming.js +539 -0
  220. package/dist/sap/ui/core/date/Buddhist.js +196 -0
  221. package/dist/sap/ui/core/date/CalendarUtils.js +65 -0
  222. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  223. package/dist/sap/ui/core/date/Gregorian.js +32 -0
  224. package/dist/sap/ui/core/date/Islamic.js +367 -0
  225. package/dist/sap/ui/core/date/Japanese.js +257 -0
  226. package/dist/sap/ui/core/date/Persian.js +394 -0
  227. package/dist/sap/ui/core/date/UI5Date.js +991 -0
  228. package/dist/sap/ui/core/date/UniversalDate.js +1324 -0
  229. package/dist/sap/ui/core/date/_Calendars.js +22 -0
  230. package/dist/sap/ui/core/format/DateFormat.js +3310 -0
  231. package/dist/sap/ui/core/format/NumberFormat.js +2835 -0
  232. package/dist/sap/ui/core/format/TimezoneUtil.js +24 -0
  233. package/package-scripts.cjs +35 -0
  234. package/package.json +46 -0
  235. package/tsconfig.json +24 -0
  236. package/used-modules.txt +52 -0
@@ -0,0 +1,196 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ // Provides class sap.ui.core.date.Buddhist
7
+ import UniversalDate from "./UniversalDate.js";
8
+ import CalendarType from "../CalendarType.js";
9
+ import _Calendars from "./_Calendars.js";
10
+ /**
11
+ * The Buddhist date class
12
+ *
13
+ * @class
14
+ * The Buddhist date implements the Thai solar calendar (BE - Buddhist Era). In this calendar
15
+ * the year is offset by 543 compared to the Gregorian calendar.
16
+ * e.g. Year 2022 CE corresponds to 2565 BE
17
+ *
18
+ *
19
+ * Before 1941 CE the year start was 1st of April, so Januar to March belong to the previous year.
20
+ * <pre>
21
+ * Month | 1-3 | 4-6 | 7-9 | 10-12 | 1-3 | 4-6 | 7-9 | 10-12 | 1-3 | 4-6 | 7-9 | 10-12 | 1-3 | 4-6 | 7-9 | 10-12 |
22
+ * CE | 1939 | 1940 | 1941 | 1942 |
23
+ * BE 2481 | 2482 | 2483 | 2484 | 2485 |
24
+ * </pre>
25
+ *
26
+ * @private
27
+ * @alias sap.ui.core.date.Buddhist
28
+ * @extends sap.ui.core.date.UniversalDate
29
+ */
30
+ var Buddhist = UniversalDate.extend("sap.ui.core.date.Buddhist", /** @lends sap.ui.core.date.Buddhist.prototype */{
31
+ constructor: function () {
32
+ var aArgs = arguments;
33
+ if (aArgs.length > 1) {
34
+ aArgs = toGregorianArguments(aArgs);
35
+ }
36
+ this.oDate = this.createDate(Date, aArgs);
37
+ this.sCalendarType = CalendarType.Buddhist;
38
+ }
39
+ });
40
+ Buddhist.UTC = function () {
41
+ var aArgs = toGregorianArguments(arguments);
42
+ return Date.UTC.apply(Date, aArgs);
43
+ };
44
+ Buddhist.now = function () {
45
+ return Date.now();
46
+ };
47
+
48
+ /**
49
+ * Find the matching Buddhist date for the given gregorian date
50
+ *
51
+ * @param {{year: int, month: int, day: int}} oGregorian Gregorian date
52
+ * @return {{year: int, month: int, day: int}} the resulting Buddhist date
53
+ */
54
+ function toBuddhist(oGregorian) {
55
+ var iEraStartYear = UniversalDate.getEraStartDate(CalendarType.Buddhist, 0).year,
56
+ iYear = oGregorian.year - iEraStartYear + 1;
57
+ // Before 1941 new year started on 1st of April
58
+ if (oGregorian.year < 1941 && oGregorian.month < 3) {
59
+ iYear -= 1;
60
+ }
61
+ if (oGregorian.year === null) {
62
+ iYear = undefined;
63
+ }
64
+ return {
65
+ year: iYear,
66
+ month: oGregorian.month,
67
+ day: oGregorian.day
68
+ };
69
+ }
70
+
71
+ /**
72
+ * Calculate gregorian year from Buddhist year and month
73
+ *
74
+ * @param {{year: int, month: int, day: int}} oBuddhist Buddhist date
75
+ * @return {{year: int, month: int, day: int}} the resulting Gregorian date
76
+ */
77
+ function toGregorian(oBuddhist) {
78
+ var iEraStartYear = UniversalDate.getEraStartDate(CalendarType.Buddhist, 0).year,
79
+ iYear = oBuddhist.year + iEraStartYear - 1;
80
+ // Before 1941 new year started on 1st of April
81
+ if (iYear < 1941 && oBuddhist.month < 3) {
82
+ iYear += 1;
83
+ }
84
+ if (oBuddhist.year === null) {
85
+ iYear = undefined;
86
+ }
87
+ return {
88
+ year: iYear,
89
+ month: oBuddhist.month,
90
+ day: oBuddhist.day
91
+ };
92
+ }
93
+
94
+ /**
95
+ * Convert arguments array from Buddhist date to Gregorian data.
96
+ *
97
+ * @param {int[]} aArgs Array with year, month, day (optional) according to Buddhist calendar
98
+ * @returns {int[]} Array with year, month, day according to Gregorian calendar
99
+ */
100
+ function toGregorianArguments(aArgs) {
101
+ var oBuddhist, oGregorian;
102
+ oBuddhist = {
103
+ year: aArgs[0],
104
+ month: aArgs[1],
105
+ day: aArgs[2] !== undefined ? aArgs[2] : 1
106
+ };
107
+ oGregorian = toGregorian(oBuddhist);
108
+ aArgs[0] = oGregorian.year;
109
+ return aArgs;
110
+ }
111
+
112
+ /**
113
+ * Get the Buddhist year from this.oDate
114
+ *
115
+ * @return {object}
116
+ */
117
+ Buddhist.prototype._getBuddhist = function () {
118
+ var oGregorian = {
119
+ year: this.oDate.getFullYear(),
120
+ month: this.oDate.getMonth(),
121
+ day: this.oDate.getDate()
122
+ };
123
+ return toBuddhist(oGregorian);
124
+ };
125
+
126
+ /**
127
+ * Set the Buddhist year to this.oDate
128
+ */
129
+ Buddhist.prototype._setBuddhist = function (oBuddhist) {
130
+ var oGregorian = toGregorian(oBuddhist);
131
+ return this.oDate.setFullYear(oGregorian.year, oGregorian.month, oGregorian.day);
132
+ };
133
+
134
+ /**
135
+ * Get the Buddhist year from this.oDate in UTC
136
+ *
137
+ * @return {object}
138
+ */
139
+ Buddhist.prototype._getUTCBuddhist = function () {
140
+ var oGregorian = {
141
+ year: this.oDate.getUTCFullYear(),
142
+ month: this.oDate.getUTCMonth(),
143
+ day: this.oDate.getUTCDate()
144
+ };
145
+ return toBuddhist(oGregorian);
146
+ };
147
+
148
+ /**
149
+ * Set the Buddhist year to this.oDate in UTC
150
+ */
151
+ Buddhist.prototype._setUTCBuddhist = function (oBuddhist) {
152
+ var oGregorian = toGregorian(oBuddhist);
153
+ return this.oDate.setUTCFullYear(oGregorian.year, oGregorian.month, oGregorian.day);
154
+ };
155
+
156
+ /*
157
+ * Override relevant getters/setters
158
+ */
159
+ Buddhist.prototype.getYear = function () {
160
+ return this._getBuddhist().year;
161
+ };
162
+ Buddhist.prototype.getFullYear = function () {
163
+ return this._getBuddhist().year;
164
+ };
165
+ Buddhist.prototype.getUTCFullYear = function () {
166
+ return this._getUTCBuddhist().year;
167
+ };
168
+ Buddhist.prototype.setYear = function (iYear) {
169
+ var oBuddhist = this._getBuddhist();
170
+ oBuddhist.year = iYear;
171
+ return this._setBuddhist(oBuddhist);
172
+ };
173
+ Buddhist.prototype.setFullYear = function (iYear, iMonth, iDay) {
174
+ var oBuddhist = this._getBuddhist();
175
+ oBuddhist.year = iYear;
176
+ if (iMonth !== undefined) {
177
+ oBuddhist.month = iMonth;
178
+ }
179
+ if (iDay !== undefined) {
180
+ oBuddhist.day = iDay;
181
+ }
182
+ return this._setBuddhist(oBuddhist);
183
+ };
184
+ Buddhist.prototype.setUTCFullYear = function (iYear, iMonth, iDay) {
185
+ var oBuddhist = this._getUTCBuddhist();
186
+ oBuddhist.year = iYear;
187
+ if (iMonth !== undefined) {
188
+ oBuddhist.month = iMonth;
189
+ }
190
+ if (iDay !== undefined) {
191
+ oBuddhist.day = iDay;
192
+ }
193
+ return this._setUTCBuddhist(oBuddhist);
194
+ };
195
+ _Calendars.set(CalendarType.Buddhist, Buddhist);
196
+ export default Buddhist;
@@ -0,0 +1,65 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ // Provides type sap.ui.core.date.CalendarUtils.
7
+ import CalendarWeekNumbering from "./CalendarWeekNumbering.js";
8
+ import Configuration from "../Configuration.js";
9
+ import LocaleData from "../LocaleData.js";
10
+ /**
11
+ * Provides calendar-related utilities.
12
+ *
13
+ * @namespace
14
+ * @alias module:sap/ui/core/date/CalendarUtils
15
+ * @public
16
+ * @since 1.108.0
17
+ */
18
+ var CalendarUtils = {
19
+ /**
20
+ * Resolves calendar week configuration.
21
+ *
22
+ * Returns an object with the following fields:
23
+ * <ul>
24
+ * <li><code>firstDayOfWeek</code>: specifies the first day of the week starting with
25
+ * <code>0</code> (which is Sunday)</li>
26
+ * <li><code>minimalDaysInFirstWeek</code>: minimal days at the beginning of the year
27
+ * which define the first calendar week</li>
28
+ * </ul>
29
+ *
30
+ * @param {sap.ui.core.date.CalendarWeekNumbering} [sCalendarWeekNumbering]
31
+ * The calendar week numbering; if omitted, the calendar week numbering of the Configuration
32
+ * is used; see {@link sap.ui.core.Configuration#getCalendarWeekNumbering}. If this value is
33
+ * <code>Default</code> the returned calendar week configuration is derived from the given
34
+ * <code>oLocale</code>.
35
+ * @param {sap.ui.core.Locale} [oLocale]
36
+ * The locale to use; if not provided, this falls back to the format locale from the
37
+ * Configuration; see {@link sap.ui.core.Configuration.FormatSettings#getFormatLocale}.
38
+ * Is only used when <code>sCalendarWeekNumbering</code> is set to <code>Default</code>.
39
+ * @returns {{firstDayOfWeek: int, minimalDaysInFirstWeek: int}|undefined}
40
+ * The calendar week configuration, or <code>undefined<code> for an invalid value of
41
+ * <code>sap.ui.core.date.CalendarWeekNumbering</code>.
42
+ * @public
43
+ * @since 1.108.0
44
+ */
45
+ getWeekConfigurationValues: function (sCalendarWeekNumbering, oLocale) {
46
+ var oLocaleData, oWeekConfigurationValues;
47
+ if (!sCalendarWeekNumbering) {
48
+ return CalendarUtils.getWeekConfigurationValues(Configuration.getCalendarWeekNumbering(), oLocale);
49
+ }
50
+ oWeekConfigurationValues = CalendarWeekNumbering.getWeekConfigurationValues(sCalendarWeekNumbering);
51
+ if (oWeekConfigurationValues) {
52
+ return oWeekConfigurationValues;
53
+ }
54
+ if (sCalendarWeekNumbering === CalendarWeekNumbering.Default) {
55
+ oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
56
+ oLocaleData = LocaleData.getInstance(oLocale);
57
+ return {
58
+ firstDayOfWeek: oLocaleData.getFirstDayOfWeek(),
59
+ minimalDaysInFirstWeek: oLocaleData.getMinimalDaysInFirstWeek()
60
+ };
61
+ }
62
+ return undefined;
63
+ }
64
+ };
65
+ export default CalendarUtils;
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ // Provides type sap.ui.core.date.CalendarWeekNumbering.
7
+ import DataType from "../../base/DataType.js";
8
+ import CalendarWeekNumbering from "../../../base/i18n/date/CalendarWeekNumbering.js";
9
+ /**
10
+ * The <code>CalendarWeekNumbering</code> enum defines how to calculate calendar weeks. Each
11
+ * value defines:
12
+ * <ul>
13
+ * <li>The first day of the week,</li>
14
+ * <li>the first week of the year.</li>
15
+ * </ul>
16
+ *
17
+ * @enum {string}
18
+ * @public
19
+ * @since 1.108.0
20
+ * @deprecated As of Version 1.120. Please use {@link module:sap/base/18n/date/CalendarWeekNumbering} instead.
21
+ * @name sap.ui.core.date.CalendarWeekNumbering
22
+ * @borrows module:sap/base/i18n/date/CalendarWeekNumbering.Default as Default
23
+ * @borrows module:sap/base/i18n/date/CalendarWeekNumbering.ISO_8601 as ISO_8601
24
+ * @borrows module:sap/base/i18n/date/CalendarWeekNumbering.MiddleEastern as MiddleEastern
25
+ * @borrows module:sap/base/i18n/date/CalendarWeekNumbering.WesternTraditional as WesternTraditional
26
+ * @borrows module:sap/base/i18n/date/CalendarWeekNumbering.getWeekConfigurationValues as getWeekConfigurationValues
27
+ */
28
+
29
+ DataType.registerEnum("sap.ui.core.date.CalendarWeekNumbering", CalendarWeekNumbering);
30
+ export default CalendarWeekNumbering;
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ // Provides class sap.ui.core.date.Gregorian
7
+ import UniversalDate from "./UniversalDate.js";
8
+ import CalendarType from "../CalendarType.js";
9
+ import _Calendars from "./_Calendars.js";
10
+ /**
11
+ * The Gregorian date class
12
+ *
13
+ * @class
14
+ *
15
+ * @private
16
+ * @alias sap.ui.core.date.Gregorian
17
+ * @extends sap.ui.core.date.UniversalDate
18
+ */
19
+ var Gregorian = UniversalDate.extend("sap.ui.core.date.Gregorian", /** @lends sap.ui.core.date.Gregorian.prototype */{
20
+ constructor: function () {
21
+ this.oDate = this.createDate(Date, arguments);
22
+ this.sCalendarType = CalendarType.Gregorian;
23
+ }
24
+ });
25
+ Gregorian.UTC = function () {
26
+ return Date.UTC.apply(Date, arguments);
27
+ };
28
+ Gregorian.now = function () {
29
+ return Date.now();
30
+ };
31
+ _Calendars.set(CalendarType.Gregorian, Gregorian);
32
+ export default Gregorian;
@@ -0,0 +1,367 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ // Provides class sap.ui.core.date.Islamic
7
+ import UniversalDate from "./UniversalDate.js";
8
+ import CalendarType from "../CalendarType.js";
9
+ import Log from "../../../base/Log.js";
10
+ import Formatting from "../../../base/i18n/Formatting.js";
11
+ import _Calendars from "./_Calendars.js";
12
+ /**
13
+ * The Islamic date class
14
+ *
15
+ * @class
16
+ * The islamic date does conversion of day, month and year values based on tabular data indicating the start of a month.
17
+ * In case no tabular data is available for the date, a fallback calculated date will be used.
18
+ *
19
+ * @private
20
+ * @alias sap.ui.core.date.Islamic
21
+ * @extends sap.ui.core.date.UniversalDate
22
+ */
23
+ var Islamic = UniversalDate.extend("sap.ui.core.date.Islamic", /** @lends sap.ui.core.date.Islamic.prototype */{
24
+ constructor: function () {
25
+ var aArgs = arguments;
26
+ if (aArgs.length > 1) {
27
+ aArgs = toGregorianArguments(aArgs);
28
+ }
29
+ this.oDate = this.createDate(Date, aArgs);
30
+ this.sCalendarType = CalendarType.Islamic;
31
+ }
32
+ });
33
+ Islamic.UTC = function () {
34
+ var aArgs = toGregorianArguments(arguments);
35
+ return Date.UTC.apply(Date, aArgs);
36
+ };
37
+ Islamic.now = function () {
38
+ return Date.now();
39
+ };
40
+ var BASE_YEAR = 1400,
41
+ // used for 2 digits "year" related method
42
+ GREGORIAN_EPOCH_DAYS = 1721425.5,
43
+ // Julian days since noon on January 1, 4713 BC
44
+ ISLAMIC_EPOCH_DAYS = 1948439.5,
45
+ // Julian days since noon on January 1, 4713 BC
46
+ ISLAMIC_MILLIS = -42521587200000,
47
+ // 7/16/622
48
+ ONE_DAY = 86400000;
49
+ var oCustomizationMap = null;
50
+
51
+ // Currently those are the two supported Islamic Calendar types in the ABAP
52
+ var aSupportedIslamicCalendarTypes = ["A", "B"];
53
+
54
+ /**
55
+ * Calculate islamic date from gregorian.
56
+ *
57
+ * @param {object} oGregorian A JS object containing day, month and year in the gregorian calendar
58
+ * @returns {object} The islamic date object created
59
+ * @private
60
+ */
61
+ function toIslamic(oGregorian) {
62
+ var iGregorianYear = oGregorian.year,
63
+ iGregorianMonth = oGregorian.month,
64
+ iGregorianDay = oGregorian.day,
65
+ iIslamicYear,
66
+ iIslamicMonth,
67
+ iIslamicDay,
68
+ iMonths,
69
+ iDays,
70
+ iLeapAdj,
71
+ iJulianDay;
72
+ iLeapAdj = 0;
73
+ if (iGregorianMonth + 1 > 2) {
74
+ iLeapAdj = isGregorianLeapYear(iGregorianYear) ? -1 : -2;
75
+ }
76
+ iJulianDay = GREGORIAN_EPOCH_DAYS - 1 + 365 * (iGregorianYear - 1) + Math.floor((iGregorianYear - 1) / 4) + -Math.floor((iGregorianYear - 1) / 100) + Math.floor((iGregorianYear - 1) / 400) + Math.floor((367 * (iGregorianMonth + 1) - 362) / 12 + iLeapAdj + iGregorianDay);
77
+ iJulianDay = Math.floor(iJulianDay) + 0.5;
78
+ iDays = iJulianDay - ISLAMIC_EPOCH_DAYS;
79
+ iMonths = Math.floor(iDays / 29.530588853); // day/CalendarAstronomer.SYNODIC_MONTH
80
+
81
+ if (iMonths < 0) {
82
+ //negative means Islamic date before the Islamic's calendar start. So we do not apply customization.
83
+ iIslamicYear = Math.floor(iMonths / 12) + 1;
84
+ iIslamicMonth = iMonths % 12;
85
+ if (iIslamicMonth < 0) {
86
+ iIslamicMonth += 12;
87
+ }
88
+ iIslamicDay = iDays - monthStart(iIslamicYear, iIslamicMonth) + 1;
89
+ } else {
90
+ /* Guess the month start.
91
+ * Always also check the next month, since customization can
92
+ * differ. It can differ for not more than 3 days. so that
93
+ * checking the next month is enough.
94
+ */
95
+ iMonths++;
96
+
97
+ /*
98
+ * Check the true month start for the given month. If it is
99
+ * later, check the previous month, until a suitable is found.
100
+ */
101
+ while (getCustomMonthStartDays(iMonths) > iDays) {
102
+ iMonths--;
103
+ }
104
+ iIslamicYear = Math.floor(iMonths / 12) + 1;
105
+ iIslamicMonth = iMonths % 12;
106
+ iIslamicDay = iDays - getCustomMonthStartDays(12 * (iIslamicYear - 1) + iIslamicMonth) + 1;
107
+ }
108
+ return {
109
+ day: iIslamicDay,
110
+ month: iIslamicMonth,
111
+ year: iIslamicYear
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Calculate gregorian date from islamic.
117
+ *
118
+ * @param {object} oIslamic A JS object containing day, month and year in the islamic calendar
119
+ * @returns {object} The gregorian date object created
120
+ * @private
121
+ */
122
+ function toGregorian(oIslamic) {
123
+ var iIslamicYear = oIslamic.year,
124
+ iIslamicMonth = oIslamic.month,
125
+ iIslamicDate = oIslamic.day,
126
+ /* Islamic Calendar starts from 0001/0/1 (19 July 622 AD), so for any date before it customization is not needed */
127
+ iMonthStart = iIslamicYear < 1 ? monthStart(iIslamicYear, iIslamicMonth) : getCustomMonthStartDays(12 * (iIslamicYear - 1) + iIslamicMonth),
128
+ iJulianDay = iIslamicDate + iMonthStart + ISLAMIC_EPOCH_DAYS - 1,
129
+ iJulianDayNoon = Math.floor(iJulianDay - 0.5) + 0.5,
130
+ iDaysSinceGregorianEpoch = iJulianDayNoon - GREGORIAN_EPOCH_DAYS,
131
+ iQuadricent = Math.floor(iDaysSinceGregorianEpoch / 146097),
132
+ iQuadricentNormalized = mod(iDaysSinceGregorianEpoch, 146097),
133
+ iCent = Math.floor(iQuadricentNormalized / 36524),
134
+ iCentNormalized = mod(iQuadricentNormalized, 36524),
135
+ iQuad = Math.floor(iCentNormalized / 1461),
136
+ iQuadNormalized = mod(iCentNormalized, 1461),
137
+ iYearIndex = Math.floor(iQuadNormalized / 365),
138
+ iYear = iQuadricent * 400 + iCent * 100 + iQuad * 4 + iYearIndex,
139
+ iMonth,
140
+ iDay,
141
+ iGregorianYearStartDays,
142
+ iDayOfYear,
143
+ tjd,
144
+ tjd2,
145
+ iLeapAdj,
146
+ iLeapAdj2;
147
+ if (!(iCent == 4 || iYearIndex == 4)) {
148
+ iYear++;
149
+ }
150
+ iGregorianYearStartDays = GREGORIAN_EPOCH_DAYS + 365 * (iYear - 1) + Math.floor((iYear - 1) / 4) - Math.floor((iYear - 1) / 100) + Math.floor((iYear - 1) / 400);
151
+ iDayOfYear = iJulianDayNoon - iGregorianYearStartDays;
152
+ tjd = GREGORIAN_EPOCH_DAYS - 1 + 365 * (iYear - 1) + Math.floor((iYear - 1) / 4) - Math.floor((iYear - 1) / 100) + Math.floor((iYear - 1) / 400) + Math.floor(739 / 12 + (isGregorianLeapYear(iYear) ? -1 : -2) + 1);
153
+ iLeapAdj = 0;
154
+ if (iJulianDayNoon < tjd) {
155
+ iLeapAdj = 0;
156
+ } else {
157
+ iLeapAdj = isGregorianLeapYear(iYear) ? 1 : 2;
158
+ }
159
+ iMonth = Math.floor(((iDayOfYear + iLeapAdj) * 12 + 373) / 367);
160
+ tjd2 = GREGORIAN_EPOCH_DAYS - 1 + 365 * (iYear - 1) + Math.floor((iYear - 1) / 4) - Math.floor((iYear - 1) / 100) + Math.floor((iYear - 1) / 400);
161
+ iLeapAdj2 = 0;
162
+ if (iMonth > 2) {
163
+ iLeapAdj2 = isGregorianLeapYear(iYear) ? -1 : -2;
164
+ }
165
+ tjd2 += Math.floor((367 * iMonth - 362) / 12 + iLeapAdj2 + 1);
166
+ iDay = iJulianDayNoon - tjd2 + 1;
167
+ return {
168
+ day: iDay,
169
+ month: iMonth - 1,
170
+ year: iYear
171
+ };
172
+ }
173
+ function toGregorianArguments(aArgs) {
174
+ var aGregorianArgs = Array.prototype.slice.call(aArgs),
175
+ oIslamic,
176
+ oGregorian;
177
+ oIslamic = {
178
+ year: aArgs[0],
179
+ month: aArgs[1],
180
+ day: aArgs[2] !== undefined ? aArgs[2] : 1
181
+ };
182
+ oGregorian = toGregorian(oIslamic);
183
+ aGregorianArgs[0] = oGregorian.year;
184
+ aGregorianArgs[1] = oGregorian.month;
185
+ aGregorianArgs[2] = oGregorian.day;
186
+ return aGregorianArgs;
187
+ }
188
+ function initCustomizationMap() {
189
+ var sDateFormat, oCustomizationJSON;
190
+ oCustomizationMap = {};
191
+ sDateFormat = Formatting.getABAPDateFormat();
192
+ sDateFormat = _isSupportedIslamicCalendarType(sDateFormat) ? sDateFormat : "A"; // set "A" as a fall-back format always
193
+ oCustomizationJSON = Formatting.getCustomIslamicCalendarData();
194
+ oCustomizationJSON = oCustomizationJSON || [];
195
+ if (!oCustomizationJSON.length) {
196
+ Log.warning("No calendar customizations.");
197
+ return;
198
+ }
199
+ oCustomizationJSON.forEach(function (oEntry) {
200
+ if (oEntry.dateFormat === sDateFormat) {
201
+ var date = parseDate(oEntry.gregDate);
202
+ // no need to use UI5Date.getInstance as only the UTC timestamp is used
203
+ var iGregorianDate = new Date(Date.UTC(date.year, date.month - 1, date.day));
204
+ var iMillis = iGregorianDate.getTime();
205
+ var iIslamicMonthStartDays = (iMillis - ISLAMIC_MILLIS) / ONE_DAY;
206
+ date = parseDate(oEntry.islamicMonthStart);
207
+ var iIslamicMonths = (date.year - 1) * 12 + date.month - 1;
208
+ oCustomizationMap[iIslamicMonths] = iIslamicMonthStartDays;
209
+ }
210
+ });
211
+ Log.info("Working with date format: [" + sDateFormat + "] and customization: " + JSON.stringify(oCustomizationJSON));
212
+ }
213
+ function parseDate(sDate) {
214
+ return {
215
+ year: parseInt(sDate.substr(0, 4)),
216
+ month: parseInt(sDate.substr(4, 2)),
217
+ day: parseInt(sDate.substr(6, 2))
218
+ };
219
+ }
220
+ function getCustomMonthStartDays(months) {
221
+ if (!oCustomizationMap) {
222
+ initCustomizationMap();
223
+ }
224
+ var iIslamicMonthStartDays = oCustomizationMap[months];
225
+ if (!iIslamicMonthStartDays) {
226
+ var year = Math.floor(months / 12) + 1;
227
+ var month = months % 12;
228
+ iIslamicMonthStartDays = monthStart(year, month);
229
+ }
230
+ return iIslamicMonthStartDays;
231
+ }
232
+ function monthStart(year, month) {
233
+ return Math.ceil(29.5 * month) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30.0);
234
+ }
235
+ function mod(a, b) {
236
+ return a - b * Math.floor(a / b);
237
+ }
238
+ function isGregorianLeapYear(iYear) {
239
+ return !(iYear % 400) || !(iYear % 4) && !!(iYear % 100);
240
+ }
241
+ function _isSupportedIslamicCalendarType(sCalendarType) {
242
+ return aSupportedIslamicCalendarTypes.indexOf(sCalendarType) !== -1;
243
+ }
244
+
245
+ /**
246
+ * Get the islamic date from the this.oDate.
247
+ * @returns {object} The islamic date object created
248
+ */
249
+ Islamic.prototype._getIslamic = function () {
250
+ return toIslamic({
251
+ day: this.oDate.getDate(),
252
+ month: this.oDate.getMonth(),
253
+ year: this.oDate.getFullYear()
254
+ });
255
+ };
256
+
257
+ /**
258
+ * Set the islamic date to the current this.oDate object.
259
+ * @param {object} oIslamic A JS object containing day, month and year in the islamic calendar
260
+ * @returns {number} <code>this</code> to allow method chaining
261
+ */
262
+ Islamic.prototype._setIslamic = function (oIslamic) {
263
+ var oGregorian = toGregorian(oIslamic);
264
+ return this.oDate.setFullYear(oGregorian.year, oGregorian.month, oGregorian.day);
265
+ };
266
+
267
+ /**
268
+ * Get the islamic date from the this.oDate.
269
+ * @returns {object} The UTC date object created
270
+ */
271
+ Islamic.prototype._getUTCIslamic = function () {
272
+ return toIslamic({
273
+ day: this.oDate.getUTCDate(),
274
+ month: this.oDate.getUTCMonth(),
275
+ year: this.oDate.getUTCFullYear()
276
+ });
277
+ };
278
+
279
+ /**
280
+ * Set the islamic date to the current this.oDate object.
281
+ * @param {object} oIslamic A JS object containing day, month and year in the islamic calendar
282
+ * @returns {number} <code>this</code> to allow method chaining
283
+ */
284
+ Islamic.prototype._setUTCIslamic = function (oIslamic) {
285
+ var oGregorian = toGregorian(oIslamic);
286
+ return this.oDate.setUTCFullYear(oGregorian.year, oGregorian.month, oGregorian.day);
287
+ };
288
+
289
+ /*
290
+ * Override setters and getters specific to the islamic date
291
+ */
292
+ Islamic.prototype.getDate = function (iDate) {
293
+ return this._getIslamic().day;
294
+ };
295
+ Islamic.prototype.getMonth = function () {
296
+ return this._getIslamic().month;
297
+ };
298
+ Islamic.prototype.getYear = function () {
299
+ return this._getIslamic().year - BASE_YEAR;
300
+ };
301
+ Islamic.prototype.getFullYear = function () {
302
+ return this._getIslamic().year;
303
+ };
304
+ Islamic.prototype.setDate = function (iDate) {
305
+ var oIslamic = this._getIslamic();
306
+ oIslamic.day = iDate;
307
+ return this._setIslamic(oIslamic);
308
+ };
309
+ Islamic.prototype.setMonth = function (iMonth, iDay) {
310
+ var oIslamic = this._getIslamic();
311
+ oIslamic.month = iMonth;
312
+ if (iDay !== undefined) {
313
+ oIslamic.day = iDay;
314
+ }
315
+ return this._setIslamic(oIslamic);
316
+ };
317
+ Islamic.prototype.setYear = function (iYear) {
318
+ var oIslamic = this._getIslamic();
319
+ oIslamic.year = iYear + BASE_YEAR;
320
+ return this._setIslamic(oIslamic);
321
+ };
322
+ Islamic.prototype.setFullYear = function (iYear, iMonth, iDay) {
323
+ var oIslamic = this._getIslamic();
324
+ oIslamic.year = iYear;
325
+ if (iMonth !== undefined) {
326
+ oIslamic.month = iMonth;
327
+ }
328
+ if (iDay !== undefined) {
329
+ oIslamic.day = iDay;
330
+ }
331
+ return this._setIslamic(oIslamic);
332
+ };
333
+ Islamic.prototype.getUTCDate = function (iDate) {
334
+ return this._getUTCIslamic().day;
335
+ };
336
+ Islamic.prototype.getUTCMonth = function () {
337
+ return this._getUTCIslamic().month;
338
+ };
339
+ Islamic.prototype.getUTCFullYear = function () {
340
+ return this._getUTCIslamic().year;
341
+ };
342
+ Islamic.prototype.setUTCDate = function (iDate) {
343
+ var oIslamic = this._getUTCIslamic();
344
+ oIslamic.day = iDate;
345
+ return this._setUTCIslamic(oIslamic);
346
+ };
347
+ Islamic.prototype.setUTCMonth = function (iMonth, iDay) {
348
+ var oIslamic = this._getUTCIslamic();
349
+ oIslamic.month = iMonth;
350
+ if (iDay !== undefined) {
351
+ oIslamic.day = iDay;
352
+ }
353
+ return this._setUTCIslamic(oIslamic);
354
+ };
355
+ Islamic.prototype.setUTCFullYear = function (iYear, iMonth, iDay) {
356
+ var oIslamic = this._getUTCIslamic();
357
+ oIslamic.year = iYear;
358
+ if (iMonth !== undefined) {
359
+ oIslamic.month = iMonth;
360
+ }
361
+ if (iDay !== undefined) {
362
+ oIslamic.day = iDay;
363
+ }
364
+ return this._setUTCIslamic(oIslamic);
365
+ };
366
+ _Calendars.set(CalendarType.Islamic, Islamic);
367
+ export default Islamic;