@ui5/webcomponents-localization 0.0.0-0fcda382e → 0.0.0-10f3c0dc7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/.eslintignore +2 -0
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +2427 -0
  4. package/LICENSE.txt +201 -0
  5. package/README.md +38 -10
  6. package/dist/.tsbuildinfo +1 -0
  7. package/dist/Assets-fetch.d.ts +1 -0
  8. package/dist/Assets-fetch.js +3 -0
  9. package/dist/Assets-fetch.js.map +1 -0
  10. package/dist/Assets-node.d.ts +11 -0
  11. package/dist/Assets-node.js +12 -0
  12. package/dist/Assets-node.js.map +1 -0
  13. package/dist/Assets.d.ts +1 -0
  14. package/dist/Assets.js +1 -0
  15. package/dist/Assets.js.map +1 -0
  16. package/dist/CalendarUtils.d.ts +3 -0
  17. package/dist/CalendarUtils.js +6 -0
  18. package/dist/CalendarUtils.js.map +1 -0
  19. package/dist/DateFormat.d.ts +28 -0
  20. package/dist/DateFormat.js +22 -2
  21. package/dist/DateFormat.js.map +1 -0
  22. package/dist/Locale.d.ts +5 -0
  23. package/dist/Locale.js +7 -0
  24. package/dist/Locale.js.map +1 -0
  25. package/dist/LocaleData.d.ts +5 -0
  26. package/dist/LocaleData.js +6 -2
  27. package/dist/LocaleData.js.map +1 -0
  28. package/dist/NumberFormat.d.ts +5 -0
  29. package/dist/NumberFormat.js +7 -0
  30. package/dist/NumberFormat.js.map +1 -0
  31. package/dist/dates/CalendarDate.d.ts +42 -0
  32. package/dist/dates/CalendarDate.js +171 -181
  33. package/dist/dates/CalendarDate.js.map +1 -0
  34. package/dist/dates/ExtremeDates.d.ts +5 -0
  35. package/dist/dates/ExtremeDates.js +29 -0
  36. package/dist/dates/ExtremeDates.js.map +1 -0
  37. package/dist/dates/UI5Date.d.ts +5 -0
  38. package/dist/dates/UI5Date.js +7 -0
  39. package/dist/dates/UI5Date.js.map +1 -0
  40. package/dist/dates/UniversalDate.d.ts +47 -0
  41. package/dist/dates/UniversalDate.js +5 -0
  42. package/dist/dates/UniversalDate.js.map +1 -0
  43. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  44. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  45. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  46. package/dist/dates/getDaysInMonth.d.ts +3 -0
  47. package/dist/dates/getDaysInMonth.js +10 -0
  48. package/dist/dates/getDaysInMonth.js.map +1 -0
  49. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  50. package/dist/dates/getRoundedTimestamp.js +15 -0
  51. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  52. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  53. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  54. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  55. package/dist/dates/modifyDateBy.d.ts +14 -0
  56. package/dist/dates/modifyDateBy.js +55 -0
  57. package/dist/dates/modifyDateBy.js.map +1 -0
  58. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  59. package/dist/dates/transformDateToSecondaryType.js +18 -0
  60. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  61. package/dist/features/calendar/Buddhist.js +1 -0
  62. package/dist/features/calendar/Buddhist.js.map +1 -0
  63. package/dist/features/calendar/Gregorian.js +1 -0
  64. package/dist/features/calendar/Gregorian.js.map +1 -0
  65. package/dist/features/calendar/Islamic.js +1 -0
  66. package/dist/features/calendar/Islamic.js.map +1 -0
  67. package/dist/features/calendar/Japanese.js +1 -0
  68. package/dist/features/calendar/Japanese.js.map +1 -0
  69. package/dist/features/calendar/Persian.js +1 -0
  70. package/dist/features/calendar/Persian.js.map +1 -0
  71. package/dist/generated/assets/cldr/Unicode-Data-Files-LICENSE.txt +39 -0
  72. package/dist/generated/assets/cldr/ar.json +2179 -728
  73. package/dist/generated/assets/cldr/ar_EG.json +2179 -728
  74. package/dist/generated/assets/cldr/ar_SA.json +2275 -825
  75. package/dist/generated/assets/cldr/bg.json +1924 -798
  76. package/dist/generated/assets/cldr/ca.json +2027 -816
  77. package/dist/generated/assets/cldr/cnr.json +6476 -0
  78. package/dist/generated/assets/cldr/cs.json +1865 -842
  79. package/dist/generated/assets/cldr/cy.json +6566 -0
  80. package/dist/generated/assets/cldr/da.json +1844 -682
  81. package/dist/generated/assets/cldr/de.json +1806 -546
  82. package/dist/generated/assets/cldr/de_AT.json +1797 -537
  83. package/dist/generated/assets/cldr/de_CH.json +1879 -611
  84. package/dist/generated/assets/cldr/el.json +1497 -383
  85. package/dist/generated/assets/cldr/el_CY.json +1497 -383
  86. package/dist/generated/assets/cldr/en.json +1990 -563
  87. package/dist/generated/assets/cldr/en_AU.json +2339 -763
  88. package/dist/generated/assets/cldr/en_GB.json +2170 -621
  89. package/dist/generated/assets/cldr/en_HK.json +2076 -628
  90. package/dist/generated/assets/cldr/en_IE.json +2038 -593
  91. package/dist/generated/assets/cldr/en_IN.json +2336 -704
  92. package/dist/generated/assets/cldr/en_NZ.json +2056 -611
  93. package/dist/generated/assets/cldr/en_PG.json +2049 -604
  94. package/dist/generated/assets/cldr/en_SG.json +2041 -593
  95. package/dist/generated/assets/cldr/en_ZA.json +2046 -599
  96. package/dist/generated/assets/cldr/es.json +2197 -881
  97. package/dist/generated/assets/cldr/es_AR.json +2167 -819
  98. package/dist/generated/assets/cldr/es_BO.json +2210 -863
  99. package/dist/generated/assets/cldr/es_CL.json +2087 -848
  100. package/dist/generated/assets/cldr/es_CO.json +1947 -707
  101. package/dist/generated/assets/cldr/es_MX.json +2446 -1091
  102. package/dist/generated/assets/cldr/es_PE.json +1912 -773
  103. package/dist/generated/assets/cldr/es_UY.json +1926 -795
  104. package/dist/generated/assets/cldr/es_VE.json +1920 -789
  105. package/dist/generated/assets/cldr/et.json +1761 -544
  106. package/dist/generated/assets/cldr/fa.json +1872 -566
  107. package/dist/generated/assets/cldr/fi.json +1959 -526
  108. package/dist/generated/assets/cldr/fr.json +1711 -460
  109. package/dist/generated/assets/cldr/fr_BE.json +1710 -459
  110. package/dist/generated/assets/cldr/fr_CA.json +2087 -814
  111. package/dist/generated/assets/cldr/fr_CH.json +1669 -418
  112. package/dist/generated/assets/cldr/fr_LU.json +1711 -460
  113. package/dist/generated/assets/cldr/he.json +2018 -1033
  114. package/dist/generated/assets/cldr/hi.json +1619 -348
  115. package/dist/generated/assets/cldr/hr.json +1855 -569
  116. package/dist/generated/assets/cldr/hu.json +1764 -551
  117. package/dist/generated/assets/cldr/id.json +1924 -601
  118. package/dist/generated/assets/cldr/it.json +1821 -666
  119. package/dist/generated/assets/cldr/it_CH.json +1827 -672
  120. package/dist/generated/assets/cldr/ja.json +1426 -109
  121. package/dist/generated/assets/cldr/kk.json +2251 -737
  122. package/dist/generated/assets/cldr/ko.json +1484 -196
  123. package/dist/generated/assets/cldr/lt.json +1714 -734
  124. package/dist/generated/assets/cldr/lv.json +1686 -682
  125. package/dist/generated/assets/cldr/mk.json +6177 -0
  126. package/dist/generated/assets/cldr/ms.json +1903 -595
  127. package/dist/generated/assets/cldr/nb.json +1548 -369
  128. package/dist/generated/assets/cldr/nl.json +1935 -511
  129. package/dist/generated/assets/cldr/nl_BE.json +1955 -531
  130. package/dist/generated/assets/cldr/pl.json +1873 -586
  131. package/dist/generated/assets/cldr/pt.json +2184 -753
  132. package/dist/generated/assets/cldr/pt_PT.json +2149 -778
  133. package/dist/generated/assets/cldr/ro.json +1847 -765
  134. package/dist/generated/assets/cldr/ru.json +2082 -755
  135. package/dist/generated/assets/cldr/ru_UA.json +2076 -749
  136. package/dist/generated/assets/cldr/sk.json +1860 -972
  137. package/dist/generated/assets/cldr/sl.json +1861 -920
  138. package/dist/generated/assets/cldr/sr.json +1829 -767
  139. package/dist/generated/assets/cldr/sr_Latn.json +6173 -0
  140. package/dist/generated/assets/cldr/sv.json +1789 -587
  141. package/dist/generated/assets/cldr/th.json +1704 -373
  142. package/dist/generated/assets/cldr/tr.json +1855 -587
  143. package/dist/generated/assets/cldr/uk.json +2166 -711
  144. package/dist/generated/assets/cldr/vi.json +2054 -709
  145. package/dist/generated/assets/cldr/zh_CN.json +1736 -397
  146. package/dist/generated/assets/cldr/zh_HK.json +1713 -374
  147. package/dist/generated/assets/cldr/zh_SG.json +1723 -384
  148. package/dist/generated/assets/cldr/zh_TW.json +1678 -371
  149. package/dist/generated/json-imports/LocaleData-fetch.d.ts +1 -0
  150. package/dist/generated/json-imports/LocaleData-fetch.js +93 -0
  151. package/dist/generated/json-imports/LocaleData-fetch.js.map +1 -0
  152. package/dist/generated/json-imports/LocaleData-node.d.ts +1 -0
  153. package/dist/generated/json-imports/LocaleData-node.js +93 -0
  154. package/dist/generated/json-imports/LocaleData-node.js.map +1 -0
  155. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  156. package/dist/generated/json-imports/LocaleData.js +92 -95
  157. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  158. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  159. package/dist/getCachedLocaleDataInstance.js +12 -0
  160. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  161. package/dist/locale/getLocaleData.d.ts +11 -0
  162. package/dist/locale/getLocaleData.js +15 -17
  163. package/dist/locale/getLocaleData.js.map +1 -0
  164. package/dist/sap/base/Event.js +59 -0
  165. package/dist/sap/base/Eventing.js +147 -0
  166. package/dist/sap/base/Log.js +2 -248
  167. package/dist/sap/base/assert.js +31 -9
  168. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  169. package/dist/sap/base/config.js +17 -0
  170. package/dist/sap/base/future.js +12 -0
  171. package/dist/sap/base/i18n/Formatting.d.ts +13 -0
  172. package/dist/sap/base/i18n/Formatting.js +18 -0
  173. package/dist/sap/base/i18n/Formatting.js.map +1 -0
  174. package/dist/sap/base/i18n/LanguageTag.js +179 -0
  175. package/dist/sap/base/i18n/Localization.d.ts +7 -0
  176. package/dist/sap/base/i18n/Localization.js +17 -0
  177. package/dist/sap/base/i18n/Localization.js.map +1 -0
  178. package/dist/sap/base/i18n/ResourceBundle.js +20 -0
  179. package/dist/sap/base/i18n/date/CalendarType.js +44 -0
  180. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +106 -0
  181. package/dist/sap/base/i18n/date/TimezoneUtils.js +471 -0
  182. package/dist/sap/base/i18n/date/_EnumHelper.js +37 -0
  183. package/dist/sap/base/strings/camelize.js +30 -0
  184. package/dist/sap/base/strings/formatMessage.js +93 -15
  185. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  186. package/dist/sap/base/util/LoaderExtensions.js +11 -4
  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 +4 -33
  190. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  191. package/dist/sap/base/util/Properties.js +12 -0
  192. package/dist/sap/base/util/Version.js +163 -0
  193. package/dist/sap/base/util/_merge.js +83 -26
  194. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  195. package/dist/sap/base/util/deepClone.js +102 -0
  196. package/dist/sap/base/util/deepEqual.js +75 -55
  197. package/dist/sap/base/util/deepExtend.js +60 -0
  198. package/dist/sap/base/util/extend.js +58 -7
  199. package/dist/sap/base/util/fetch.js +8 -0
  200. package/dist/sap/base/util/isEmptyObject.js +34 -0
  201. package/dist/sap/base/util/isPlainObject.js +35 -1
  202. package/dist/sap/base/util/merge.js +57 -0
  203. package/dist/sap/base/util/mixedFetch.js +3 -0
  204. package/dist/sap/base/util/now.js +22 -7
  205. package/dist/sap/base/util/resolveReference.js +3 -0
  206. package/dist/sap/base/util/uid.js +27 -0
  207. package/dist/sap/ui/Device.js +25 -3
  208. package/dist/sap/ui/Global.js +1 -0
  209. package/dist/sap/ui/VersionInfo.js +14 -0
  210. package/dist/sap/ui/base/DataType.js +708 -0
  211. package/dist/sap/ui/base/DesignTime.js +11 -0
  212. package/dist/sap/ui/base/EventProvider.js +21 -0
  213. package/dist/sap/ui/base/Interface.js +50 -6
  214. package/dist/sap/ui/base/Metadata.js +470 -173
  215. package/dist/sap/ui/base/Object.js +287 -27
  216. package/dist/sap/ui/base/OwnStatics.js +6 -0
  217. package/dist/sap/ui/base/SyncPromise.js +98 -0
  218. package/dist/sap/ui/core/AnimationMode.js +42 -0
  219. package/dist/sap/ui/core/CalendarType.js +24 -8
  220. package/dist/sap/ui/core/Configuration.d.ts +17 -0
  221. package/dist/sap/ui/core/Configuration.js +23 -0
  222. package/dist/sap/ui/core/Configuration.js.map +1 -0
  223. package/dist/sap/ui/core/ControlBehavior.js +11 -0
  224. package/dist/sap/ui/core/Core.d.ts +25 -0
  225. package/dist/sap/ui/core/Core.js +7 -32
  226. package/dist/sap/ui/core/Core.js.map +1 -0
  227. package/dist/sap/ui/core/FormatSettings.d.ts +9 -0
  228. package/dist/sap/ui/core/FormatSettings.js +12 -0
  229. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  230. package/dist/sap/ui/core/Lib.js +41 -0
  231. package/dist/sap/ui/core/Locale.js +190 -116
  232. package/dist/sap/ui/core/LocaleData.js +2837 -2683
  233. package/dist/sap/ui/core/Supportability.js +5 -0
  234. package/dist/sap/ui/core/Theming.js +39 -0
  235. package/dist/sap/ui/core/_UrlResolver.js +11 -0
  236. package/dist/sap/ui/core/date/Buddhist.js +162 -93
  237. package/dist/sap/ui/core/date/CalendarUtils.js +67 -0
  238. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  239. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  240. package/dist/sap/ui/core/date/Islamic.js +298 -185
  241. package/dist/sap/ui/core/date/Japanese.js +212 -117
  242. package/dist/sap/ui/core/date/Persian.js +324 -195
  243. package/dist/sap/ui/core/date/UI5Date.js +1039 -0
  244. package/dist/sap/ui/core/date/UniversalDate.js +1241 -217
  245. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  246. package/dist/sap/ui/core/format/DateFormat.js +3160 -1781
  247. package/dist/sap/ui/core/format/FormatUtils.js +30 -0
  248. package/dist/sap/ui/core/format/NumberFormat.js +3164 -0
  249. package/dist/sap/ui/core/format/TimezoneUtil.js +93 -0
  250. package/dist/sap/ui/core/getCompatibilityVersion.js +7 -0
  251. package/dist/sap/ui/core/theming/ThemeHelper.js +14 -0
  252. package/dist/sap/ui/security/Security.js +12 -0
  253. package/dist/sap/ui/util/XMLHelper.js +11 -0
  254. package/dist/sap/ui/util/_URL.js +1 -0
  255. package/dist/ui5loader-autoconfig.js +1 -0
  256. package/package-scripts.cjs +35 -0
  257. package/package.json +27 -21
  258. package/tsconfig.json +24 -0
  259. package/used-modules.txt +33 -1
  260. package/dist/dates/calculateWeekNumber.js +0 -51
  261. package/package-scripts.js +0 -31
  262. package/src/Assets.js +0 -2
  263. package/src/DateFormat.js +0 -3
  264. package/src/LocaleData.js +0 -3
  265. package/src/dates/CalendarDate.js +0 -203
  266. package/src/dates/calculateWeekNumber.js +0 -51
  267. package/src/locale/getLocaleData.js +0 -27
  268. package/src/sap/base/util/LoaderExtensions.js +0 -7
  269. package/src/sap/ui/core/Core.js +0 -38
  270. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  271. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  272. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  273. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  274. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  275. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -0,0 +1,471 @@
1
+ /**
2
+ * Static collection of utility functions to handle time zone related conversions
3
+ *
4
+ * @author SAP SE
5
+ * @version 1.146.0
6
+ * @namespace
7
+ * @alias module:sap/base/i18n/date/TimezoneUtils
8
+ * @private
9
+ */ /*!
10
+ * OpenUI5
11
+ * (c) Copyright 2026 SAP SE or an SAP affiliate company.
12
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
13
+ */
14
+
15
+ var TimezoneUtils = {};
16
+
17
+ /**
18
+ * Cache for the (browser's) local IANA timezone ID
19
+ *
20
+ * @type {string}
21
+ */
22
+ var sLocalTimezone = "";
23
+
24
+ /**
25
+ * Cache for valid time zones provided by <code>Intl.supportedValuesOf("timeZone")</code>
26
+ *
27
+ * @type {Array}
28
+ */
29
+ var aSupportedTimezoneIDs;
30
+
31
+ /**
32
+ * Cache for Intl.DateTimeFormat instances
33
+ */
34
+ var oIntlDateTimeFormatCache = {
35
+ _oCache: new Map(),
36
+ /**
37
+ * When cache limit is reached, it gets cleared
38
+ */
39
+ _iCacheLimit: 10,
40
+ /**
41
+ * Creates or gets an instance of Intl.DateTimeFormat.
42
+ *
43
+ * @param {string} sTimezone IANA timezone ID
44
+ * @returns {Intl.DateTimeFormat} Intl.DateTimeFormat instance
45
+ */
46
+ get: function (sTimezone) {
47
+ var cacheEntry = this._oCache.get(sTimezone);
48
+ if (cacheEntry) {
49
+ return cacheEntry;
50
+ }
51
+ var oOptions = {
52
+ hourCycle: "h23",
53
+ hour: "2-digit",
54
+ minute: "2-digit",
55
+ second: "2-digit",
56
+ fractionalSecondDigits: 3,
57
+ day: "2-digit",
58
+ month: "2-digit",
59
+ year: "numeric",
60
+ timeZone: sTimezone,
61
+ timeZoneName: 'short',
62
+ era: 'narrow',
63
+ weekday: "short"
64
+ };
65
+ var oInstance = new Intl.DateTimeFormat("en-US", oOptions);
66
+
67
+ // only store a limited number of entries in the cache
68
+ if (this._oCache.size === this._iCacheLimit) {
69
+ this._oCache = new Map();
70
+ }
71
+ this._oCache.set(sTimezone, oInstance);
72
+ return oInstance;
73
+ }
74
+ };
75
+
76
+ /**
77
+ * Uses the <code>Intl.supportedValuesOf('timeZone')</code> and <code>Intl.DateTimeFormat</code>
78
+ * API to check if the browser can handle the given IANA timezone ID.
79
+ * <code>Intl.supportedValuesOf('timeZone')</code> offers direct access to the list of supported
80
+ * time zones. It is not yet supported by all browsers but if it is supported and the given time
81
+ * zone is in the list it is faster than probing.
82
+ *
83
+ * <code>Intl.supportedValuesOf('timeZone')</code> does not return all IANA timezone IDs which
84
+ * the <code>Intl.DateTimeFormat</code> can handle, e.g. "Japan", "Etc/UTC".
85
+ *
86
+ * @param {string} sTimezone The IANA timezone ID which is checked, e.g <code>"Europe/Berlin"</code>
87
+ * @returns {boolean} Whether the time zone is a valid IANA timezone ID
88
+ * @private
89
+ * @ui5-restricted sap.ui.comp.util.DateTimeUtil, sap.ui.core.format.DateFormat, sap.viz,
90
+ * sap/base/i18n/Localization, sap/ui/core/format/TimezoneUtil
91
+ */
92
+ TimezoneUtils.isValidTimezone = function (sTimezone) {
93
+ if (!sTimezone) {
94
+ return false;
95
+ }
96
+ if (Intl.supportedValuesOf) {
97
+ try {
98
+ aSupportedTimezoneIDs = aSupportedTimezoneIDs || Intl.supportedValuesOf('timeZone');
99
+ if (aSupportedTimezoneIDs.includes(sTimezone)) {
100
+ return true;
101
+ }
102
+ // although not contained in the supportedValues it still can be valid, therefore continue
103
+ } catch (oError) {
104
+ // ignore error
105
+ aSupportedTimezoneIDs = [];
106
+ }
107
+ }
108
+ try {
109
+ oIntlDateTimeFormatCache.get(sTimezone);
110
+ return true;
111
+ } catch (oError) {
112
+ return false;
113
+ }
114
+ };
115
+
116
+ /**
117
+ * Converts a date to a specific time zone.
118
+ * The resulting date reflects the given time zone such that the "UTC" Date methods
119
+ * can be used, e.g. Date#getUTCHours() to display the hours in the given time zone.
120
+ *
121
+ * @example
122
+ * var oDate = new Date("2021-10-13T15:22:33Z"); // UTC
123
+ * // time zone difference UTC-4 (DST)
124
+ * TimezoneUtils.convertToTimezone(oDate, "America/New_York");
125
+ * // result is:
126
+ * // 2021-10-13 11:22:33 in America/New_York
127
+ * // same as new Date("2021-10-13T11:22:33Z"); // UTC
128
+ *
129
+ * @param {Date} oDate The date which should be converted.
130
+ * @param {string} sTargetTimezone The target IANA timezone ID, e.g <code>"Europe/Berlin"</code>
131
+ * @returns {Date} The new date in the target time zone.
132
+ * @private
133
+ * @ui5-restricted sap.ui.core.format.DateFormat, sap.ui.comp.util.DateTimeUtil, sap.viz,
134
+ * sap/ui/core/format/TimezoneUtil
135
+ */
136
+ TimezoneUtils.convertToTimezone = function (oDate, sTargetTimezone) {
137
+ var oFormatParts = this._getParts(oDate, sTargetTimezone);
138
+ return TimezoneUtils._getDateFromParts(oFormatParts);
139
+ };
140
+
141
+ /**
142
+ * Uses the <code>Intl.DateTimeFormat</code> API to convert a date to a specific time zone.
143
+ *
144
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts
145
+ * @param {Date} oDate The date which should be converted.
146
+ * @param {string} sTargetTimezone The target IANA timezone ID, e.g <code>"Europe/Berlin"</code>
147
+ * @returns {{
148
+ * day: string,
149
+ * era: string,
150
+ * fractionalSecond: string,
151
+ * hour: string,
152
+ * minute: string,
153
+ * month: string,
154
+ * second: string,
155
+ * timeZoneName: string,
156
+ * weekday: string,
157
+ * year: string
158
+ * }} An object containing the date and time fields considering the target time zone.
159
+ * @private
160
+ * @ui5-restricted sap.viz, sap/ui/core/date/UI5Date, sap/ui/core/format/TimezoneUtil
161
+ */
162
+ TimezoneUtils._getParts = function (oDate, sTargetTimezone) {
163
+ var sKey,
164
+ oPart,
165
+ oDateParts = Object.create(null),
166
+ oIntlDate = oIntlDateTimeFormatCache.get(sTargetTimezone),
167
+ // clone the date object before passing it to the Intl API, to ensure that no
168
+ // UniversalDate gets passed to it;
169
+ // no need to use UI5Date.getInstance as only the UTC timestamp is used
170
+ oParts = oIntlDate.formatToParts(new Date(oDate.getTime()));
171
+ for (sKey in oParts) {
172
+ oPart = oParts[sKey];
173
+ if (oPart.type !== "literal") {
174
+ oDateParts[oPart.type] = oPart.value;
175
+ }
176
+ }
177
+ return oDateParts;
178
+ };
179
+
180
+ /**
181
+ * Creates a Date from the provided date parts.
182
+ *
183
+ * @param {object} oParts Separated date and time fields as object, see {@link #_getParts}.
184
+ * @returns {Date} Returns the date object created from the provided parts.
185
+ * @private
186
+ * @ui5-restricted sap.viz, sap/ui/core/date/UI5Date, sap/ui/core/format/TimezoneUtil
187
+ */
188
+ TimezoneUtils._getDateFromParts = function (oParts) {
189
+ // no need to use UI5Date.getInstance as only the UTC timestamp is used
190
+ var oDate = new Date(0),
191
+ iUTCYear = parseInt(oParts.year);
192
+ if (oParts.era === "B") {
193
+ // The JS Date uses astronomical year numbering which supports year zero and negative
194
+ // year numbers.
195
+ // The Intl.DateTimeFormat API uses eras (no year zero and no negative year numbers).
196
+ // years around zero overview:
197
+ // | Astronomical | In Era
198
+ // | 2 | 2 Anno Domini (era: "A")
199
+ // | 1 | 1 Anno Domini (era: "A")
200
+ // | 0 | 1 Before Christ (era: "B")
201
+ // | -1 | 2 Before Christ (era: "B")
202
+ // | -2 | 3 Before Christ (era: "B")
203
+ // For the conversion to the JS Date the parts returned by the Intl.DateTimeFormat API
204
+ // need to be adapted.
205
+ iUTCYear = iUTCYear * -1 + 1;
206
+ }
207
+
208
+ // Date.UTC cannot be used here to be able to support dates before the UNIX epoch
209
+ oDate.setUTCFullYear(iUTCYear, parseInt(oParts.month) - 1, parseInt(oParts.day));
210
+ oDate.setUTCHours(parseInt(oParts.hour), parseInt(oParts.minute), parseInt(oParts.second), parseInt(oParts.fractionalSecond || 0)); // some older browsers don't support fractionalSecond, e.g. Safari < 14.1 */
211
+
212
+ return oDate;
213
+ };
214
+
215
+ /**
216
+ * Gets the offset to UTC in seconds for a given date in the time zone specified.
217
+ *
218
+ * For non-unique points in time, the daylight saving time takes precedence over the standard
219
+ * time shortly after the switch back (e.g. clock gets set back 1 hour, duplicate hour).
220
+ *
221
+ * @example
222
+ * var oDate = new Date("2021-10-13T13:22:33Z");
223
+ * TimezoneUtils.calculateOffset(oDate, "America/New_York");
224
+ * // => +14400 seconds (4 * 60 * 60 seconds)
225
+ *
226
+ * TimezoneUtils.calculateOffset(oDate, "Europe/Berlin");
227
+ * // => -7200 seconds (-2 * 60 * 60 seconds)
228
+ *
229
+ * // daylight saving time (2018 Sun, 25 Mar, 02:00 CET → CEST +1 hour (DST start) UTC+2h)
230
+ * // the given date is taken as it is in the time zone
231
+ * TimezoneUtils.calculateOffset(new Date("2018-03-25T00:00:00Z"), "Europe/Berlin");
232
+ * // => -3600 seconds (-1 * 60 * 60 seconds), interpreted as: 2018-03-25 00:00:00 (CET)
233
+ *
234
+ * TimezoneUtils.calculateOffset(new Date("2018-03-25T03:00:00Z"), "Europe/Berlin");
235
+ * // => -7200 seconds (-2 * 60 * 60 seconds)
236
+ *
237
+ * var oHistoricalDate = new Date("1800-10-13T13:22:33Z");
238
+ * TimezoneUtils.calculateOffset(oHistoricalDate, "Europe/Berlin");
239
+ * // => -3208 seconds (-3208 seconds)
240
+ *
241
+ * @param {Date} oDate The date in the time zone used to calculate the offset to UTC.
242
+ * @param {string} sTimezoneSource The source IANA timezone ID, e.g <code>"Europe/Berlin"</code>
243
+ * @returns {number} The difference to UTC between the date in the time zone.
244
+ * @private
245
+ * @ui5-restricted sap.ui.core.format.DateFormat, sap.viz, sap/ui/core/date/UI5Date,
246
+ * sap/ui/core/format/TimezoneUtil
247
+ */
248
+ TimezoneUtils.calculateOffset = function (oDate, sTimezoneSource) {
249
+ const oDateInTimezone = TimezoneUtils.convertToTimezone(oDate, sTimezoneSource);
250
+ const iGivenTimestamp = oDate.getTime();
251
+ const iInitialOffset = iGivenTimestamp - oDateInTimezone.getTime();
252
+ // no need to use UI5Date.getInstance as only the UTC timestamp is used
253
+ const oFirstGuess = new Date(iGivenTimestamp + iInitialOffset);
254
+ const oFirstGuessInTimezone = TimezoneUtils.convertToTimezone(oFirstGuess, sTimezoneSource);
255
+ const iFirstGuessInTimezoneTimestamp = oFirstGuessInTimezone.getTime();
256
+ const iSecondOffset = oFirstGuess.getTime() - iFirstGuessInTimezoneTimestamp;
257
+ let iTimezoneOffset = iSecondOffset;
258
+ if (iInitialOffset !== iSecondOffset) {
259
+ const oSecondGuess = new Date(iGivenTimestamp + iSecondOffset);
260
+ const oSecondGuessInTimezone = TimezoneUtils.convertToTimezone(oSecondGuess, sTimezoneSource);
261
+ const iSecondGuessInTimezoneTimestamp = oSecondGuessInTimezone.getTime();
262
+ // if time is different, the given date/time does not exist in the target time zone (switch to Daylight
263
+ // Saving Time) -> take the offset for the greater date
264
+ if (iSecondGuessInTimezoneTimestamp !== iGivenTimestamp && iFirstGuessInTimezoneTimestamp > iSecondGuessInTimezoneTimestamp) {
265
+ iTimezoneOffset = iInitialOffset;
266
+ }
267
+ }
268
+ return iTimezoneOffset / 1000;
269
+ };
270
+
271
+ /**
272
+ * Map outdated IANA timezone IDs used in CLDR to correct and IANA IDs as maintained in ABAP systems.
273
+ *
274
+ * @private
275
+ */
276
+ TimezoneUtils.mTimezoneAliases2ABAPTimezones = {
277
+ "Africa/Asmera": "Africa/Asmara",
278
+ "Africa/Timbuktu": "Africa/Bamako",
279
+ "America/Argentina/ComodRivadavia": "America/Argentina/Catamarca",
280
+ "America/Atka": "America/Adak",
281
+ "America/Buenos_Aires": "America/Argentina/Buenos_Aires",
282
+ "America/Catamarca": "America/Argentina/Catamarca",
283
+ "America/Coral_Harbour": "America/Atikokan",
284
+ "America/Cordoba": "America/Argentina/Cordoba",
285
+ "America/Ensenada": "America/Tijuana",
286
+ "America/Fort_Wayne": "America/Indiana/Indianapolis",
287
+ "America/Godthab": "America/Nuuk",
288
+ "America/Indianapolis": "America/Indiana/Indianapolis",
289
+ "America/Jujuy": "America/Argentina/Jujuy",
290
+ "America/Knox_IN": "America/Indiana/Knox",
291
+ "America/Louisville": "America/Kentucky/Louisville",
292
+ "America/Mendoza": "America/Argentina/Mendoza",
293
+ "America/Montreal": "America/Toronto",
294
+ "America/Nipigon": "America/Toronto",
295
+ "America/Pangnirtung": "America/Iqaluit",
296
+ "America/Porto_Acre": "America/Rio_Branco",
297
+ "America/Rainy_River": "America/Winnipeg",
298
+ "America/Rosario": "America/Argentina/Cordoba",
299
+ "America/Santa_Isabel": "America/Tijuana",
300
+ "America/Shiprock": "America/Denver",
301
+ "America/Thunder_Bay": "America/Toronto",
302
+ "America/Virgin": "America/St_Thomas",
303
+ "America/Yellowknife": "America/Edmonton",
304
+ "Antarctica/South_Pole": "Antarctica/McMurdo",
305
+ "Asia/Ashkhabad": "Asia/Ashgabat",
306
+ "Asia/Calcutta": "Asia/Kolkata",
307
+ "Asia/Choibalsan": "Asia/Ulaanbaatar",
308
+ "Asia/Chongqing": "Asia/Shanghai",
309
+ "Asia/Chungking": "Asia/Shanghai",
310
+ "Asia/Dacca": "Asia/Dhaka",
311
+ "Asia/Harbin": "Asia/Shanghai",
312
+ "Asia/Istanbul": "Europe/Istanbul",
313
+ "Asia/Kashgar": "Asia/Urumqi",
314
+ "Asia/Katmandu": "Asia/Kathmandu",
315
+ "Asia/Macao": "Asia/Macau",
316
+ "Asia/Rangoon": "Asia/Yangon",
317
+ "Asia/Saigon": "Asia/Ho_Chi_Minh",
318
+ "Asia/Tel_Aviv": "Asia/Jerusalem",
319
+ "Asia/Thimbu": "Asia/Thimphu",
320
+ "Asia/Ujung_Pandang": "Asia/Makassar",
321
+ "Asia/Ulan_Bator": "Asia/Ulaanbaatar",
322
+ "Atlantic/Faeroe": "Atlantic/Faroe",
323
+ "Atlantic/Jan_Mayen": "Arctic/Longyearbyen",
324
+ "Australia/ACT": "Australia/Sydney",
325
+ "Australia/Canberra": "Australia/Sydney",
326
+ "Australia/Currie": "Australia/Hobart",
327
+ "Australia/LHI": "Australia/Lord_Howe",
328
+ "Australia/NSW": "Australia/Sydney",
329
+ "Australia/North": "Australia/Darwin",
330
+ "Australia/Queensland": "Australia/Brisbane",
331
+ "Australia/South": "Australia/Adelaide",
332
+ "Australia/Tasmania": "Australia/Hobart",
333
+ "Australia/Victoria": "Australia/Melbourne",
334
+ "Australia/West": "Australia/Perth",
335
+ "Australia/Yancowinna": "Australia/Broken_Hill",
336
+ "Brazil/Acre": "America/Rio_Branco",
337
+ "Brazil/DeNoronha": "America/Noronha",
338
+ "Brazil/East": "America/Sao_Paulo",
339
+ "Brazil/West": "America/Manaus",
340
+ "CET": "Europe/Brussels",
341
+ "CST6CDT": "America/Chicago",
342
+ "Canada/Atlantic": "America/Halifax",
343
+ "Canada/Central": "America/Winnipeg",
344
+ "Canada/East-Saskatchewan": "America/Regina",
345
+ "Canada/Eastern": "America/Toronto",
346
+ "Canada/Mountain": "America/Edmonton",
347
+ "Canada/Newfoundland": "America/St_Johns",
348
+ "Canada/Pacific": "America/Vancouver",
349
+ "Canada/Saskatchewan": "America/Regina",
350
+ "Canada/Yukon": "America/Whitehorse",
351
+ "Chile/Continental": "America/Santiago",
352
+ "Chile/EasterIsland": "Pacific/Easter",
353
+ "Cuba": "America/Havana",
354
+ "EET": "Europe/Athens",
355
+ "EST": "America/Panama",
356
+ "EST5EDT": "America/New_York",
357
+ "Egypt": "Africa/Cairo",
358
+ "Eire": "Europe/Dublin",
359
+ "Etc/GMT+0": "Etc/GMT",
360
+ "Etc/GMT-0": "Etc/GMT",
361
+ "Etc/GMT0": "Etc/GMT",
362
+ "Etc/Greenwich": "Etc/GMT",
363
+ "Etc/UCT": "Etc/UTC",
364
+ "Etc/Zulu": "Etc/UTC",
365
+ "Europe/Belfast": "Europe/London",
366
+ "Europe/Kyiv": "Europe/Kiev",
367
+ "Europe/Nicosia": "Asia/Nicosia",
368
+ "Europe/Tiraspol": "Europe/Chisinau",
369
+ "Europe/Uzhgorod": "Europe/Kiev",
370
+ "Europe/Zaporozhye": "Europe/Kiev",
371
+ "GB": "Europe/London",
372
+ "GB-Eire": "Europe/London",
373
+ "GMT": "Etc/GMT",
374
+ "GMT+0": "Etc/GMT",
375
+ "GMT-0": "Etc/GMT",
376
+ "GMT0": "Etc/GMT",
377
+ "Greenwich": "Etc/GMT",
378
+ "HST": "Pacific/Honolulu",
379
+ "Hongkong": "Asia/Hong_Kong",
380
+ "Iceland": "Atlantic/Reykjavik",
381
+ "Iran": "Asia/Tehran",
382
+ "Israel": "Asia/Jerusalem",
383
+ "Jamaica": "America/Jamaica",
384
+ "Japan": "Asia/Tokyo",
385
+ "Kwajalein": "Pacific/Kwajalein",
386
+ "Libya": "Africa/Tripoli",
387
+ "MET": "Europe/Brussels",
388
+ "MST": "America/Phoenix",
389
+ "MST7MDT": "America/Denver",
390
+ "Mexico/BajaNorte": "America/Tijuana",
391
+ "Mexico/BajaSur": "America/Mazatlan",
392
+ "Mexico/General": "America/Mexico_City",
393
+ "NZ": "Pacific/Auckland",
394
+ "NZ-CHAT": "Pacific/Chatham",
395
+ "Navajo": "America/Denver",
396
+ "PRC": "Asia/Shanghai",
397
+ "PST8PDT": "America/Los_Angeles",
398
+ "Pacific/Enderbury": "Pacific/Kanton",
399
+ "Pacific/Johnston": "Pacific/Honolulu",
400
+ "Pacific/Ponape": "Pacific/Pohnpei",
401
+ "Pacific/Samoa": "Pacific/Pago_Pago",
402
+ "Pacific/Truk": "Pacific/Chuuk",
403
+ "Pacific/Yap": "Pacific/Chuuk",
404
+ "Poland": "Europe/Warsaw",
405
+ "Portugal": "Europe/Lisbon",
406
+ "ROC": "Asia/Taipei",
407
+ "ROK": "Asia/Seoul",
408
+ "Singapore": "Asia/Singapore",
409
+ "Turkey": "Europe/Istanbul",
410
+ "UCT": "Etc/UTC",
411
+ "US/Alaska": "America/Anchorage",
412
+ "US/Aleutian": "America/Adak",
413
+ "US/Arizona": "America/Phoenix",
414
+ "US/Central": "America/Chicago",
415
+ "US/East-Indiana": "America/Indiana/Indianapolis",
416
+ "US/Eastern": "America/New_York",
417
+ "US/Hawaii": "Pacific/Honolulu",
418
+ "US/Indiana-Starke": "America/Indiana/Knox",
419
+ "US/Michigan": "America/Detroit",
420
+ "US/Mountain": "America/Denver",
421
+ "US/Pacific": "America/Los_Angeles",
422
+ "US/Pacific-New": "America/Los_Angeles",
423
+ "US/Samoa": "Pacific/Pago_Pago",
424
+ "UTC": "Etc/UTC",
425
+ "Universal": "Etc/UTC",
426
+ "W-SU": "Europe/Moscow",
427
+ "WET": "Europe/Lisbon",
428
+ "Zulu": "Etc/UTC"
429
+ };
430
+
431
+ /**
432
+ * Retrieves the browser's local IANA timezone ID; if the browser's timezone ID is not the up-to-date IANA
433
+ * timezone ID, the corresponding IANA timezone ID is returned.
434
+ *
435
+ * @returns {string} The local IANA timezone ID of the browser as up-to-date IANA timezone ID,
436
+ * e.g. <code>"Europe/Berlin"</code> or <code>"Asia/Kolkata"</code>
437
+ *
438
+ * @private
439
+ * @ui5-restricted sap.gantt, sap.gantt, sap.viz, lib/cldr-openui5/lib/Generator,
440
+ * sap/base/i18n/Localization, sap/ui/core/date/UI5Date, sap/ui/core/format/TimezoneUtil
441
+ */
442
+ TimezoneUtils.getLocalTimezone = function () {
443
+ if (sLocalTimezone === "") {
444
+ // timezone may be undefined, only value "" means empty cache
445
+ sLocalTimezone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
446
+ sLocalTimezone = TimezoneUtils.getABAPTimezone(sLocalTimezone);
447
+ }
448
+ return sLocalTimezone;
449
+ };
450
+
451
+ /**
452
+ * Returns the ABAP time zone ID for the given IANA time zone ID.
453
+ *
454
+ * @param {string} sTimezone The IANA time zone ID
455
+ *
456
+ * @returns {string} The ABAP time zone ID
457
+ * @private
458
+ */
459
+ TimezoneUtils.getABAPTimezone = function (sTimezone) {
460
+ return TimezoneUtils.mTimezoneAliases2ABAPTimezones[sTimezone] || sTimezone;
461
+ };
462
+
463
+ /**
464
+ * Clears the cache for the browser's local IANA timezone ID.
465
+ *
466
+ * @private
467
+ */
468
+ TimezoneUtils._clearLocalTimezoneCache = function () {
469
+ sLocalTimezone = "";
470
+ };
471
+ export default TimezoneUtils;
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2026 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ let _fnRegisterEnum;
8
+ const mEarlyRegistrations = new Map();
9
+ export default {
10
+ /**
11
+ * The final registerEnum function is injected from the DataType class.
12
+ * @param {function} registerEnum the final registerEnum function of the DataType class
13
+ */
14
+ inject: function (registerEnum) {
15
+ if (!_fnRegisterEnum) {
16
+ _fnRegisterEnum = registerEnum;
17
+ mEarlyRegistrations.forEach((mEnumContent, sName) => {
18
+ _fnRegisterEnum(sName, mEnumContent);
19
+ });
20
+ }
21
+ },
22
+ /**
23
+ * Registers an enum.
24
+ * While the final registerEnum() function is not injected yet,
25
+ * the enums are collected and will be correctly registered once the DataType class injects
26
+ * its registerEnum() function.
27
+ * @param {*} sName the name of the enum in dot-syntax
28
+ * @param {*} mEnumContent the enum content
29
+ */
30
+ register: function (sName, mEnumContent) {
31
+ if (_fnRegisterEnum) {
32
+ _fnRegisterEnum(sName, mEnumContent);
33
+ } else {
34
+ mEarlyRegistrations.set(sName, mEnumContent);
35
+ }
36
+ }
37
+ };
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2026 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ var rCamelCase = /-(.)/ig;
8
+
9
+ /**
10
+ * Transforms a hyphen separated string to a camel case string.
11
+ *
12
+ * @example
13
+ * sap.ui.require(["sap/base/strings/camelize"], function(camelize){
14
+ * camelize("foo-bar"); // "fooBar"
15
+ * });
16
+ *
17
+ * @function
18
+ * @since 1.58
19
+ * @alias module:sap/base/strings/camelize
20
+ * @param {string} sString Hyphen separated string
21
+ * @returns {string} The transformed string
22
+ * @public
23
+ * @SecPassthrough {0|return}
24
+ */
25
+ var fnCamelize = function (sString) {
26
+ return sString.replace(rCamelCase, function (sMatch, sChar) {
27
+ return sChar.toUpperCase();
28
+ });
29
+ };
30
+ export default fnCamelize;
@@ -1,20 +1,98 @@
1
- import assert from '../assert.js';
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2026 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ import assert from "../assert.js";
7
+ /**
8
+ * Pattern to analyze MessageFormat strings.
9
+ *
10
+ * Group 1: captures doubled single quotes within the string
11
+ * Group 2: captures quoted fragments within the string.
12
+ * Note that java.util.MessageFormat silently forgives a missing single quote at
13
+ * the end of a pattern. This special case is handled by the RegEx as well.
14
+ * Group 3: captures placeholders
15
+ * Checks only for numerical argument index, any remainder is ignored up to the next
16
+ * closing curly brace. Nested placeholders are not accepted!
17
+ * Group 4: captures any remaining curly braces and indicates syntax errors
18
+ *
19
+ * [-1] [----- quoted string -----] [------ placeholder ------] [--]
20
+ * @private
21
+ */
2
22
  var rMessageFormat = /('')|'([^']+(?:''[^']*)*)(?:'|$)|\{([0-9]+(?:\s*,[^{}]*)?)\}|[{}]/g;
23
+
24
+ /**
25
+ * Creates a string from a pattern by replacing placeholders with concrete values.
26
+ *
27
+ * The syntax of the pattern is inspired by (but not fully equivalent to) the
28
+ * java.util.MessageFormat.
29
+ *
30
+ * Placeholders have the form <code>{ integer }</code>, where any occurrence of
31
+ * <code>{0}</code> is replaced by the value with index 0 in <code>aValues</code>,
32
+ * <code>{1}</code> by the value with index 1 in <code>aValues</code> etc.
33
+ *
34
+ * To avoid interpretation of curly braces as placeholders, any non-placeholder fragment
35
+ * of the pattern can be enclosed in single quotes. The surrounding single quotes will be
36
+ * omitted from the result. Single quotes that are not meant to escape a fragment and
37
+ * that should appear in the result, need to be doubled. In the result, only a single
38
+ * single quote will occur.
39
+ *
40
+ * Example: Pattern Strings
41
+ * <pre>
42
+ * formatMessage("Say {0}", ["Hello"]) -> "Say Hello" // normal use case
43
+ * formatMessage("Say '{0}'", ["Hello"]) -> "Say {0}" // escaped placeholder
44
+ * formatMessage("Say ''{0}''", ["Hello"]) -> "Say 'Hello'" // doubled single quote
45
+ * formatMessage("Say '{0}'''", ["Hello"]) -> "Say {0}'" // doubled single quote in quoted fragment
46
+ * </pre>
47
+ * In contrast to java.util.MessageFormat, format types or format styles are not supported.
48
+ * Everything after the argument index and up to the first closing curly brace is ignored.
49
+ * Nested placeholders (as supported by java.lang.MessageFormat for the format type choice)
50
+ * are not ignored but reported as a parse error.
51
+ *
52
+ * This method throws an Error when the pattern syntax is not fulfilled (e.g. unbalanced curly
53
+ * braces, nested placeholders or a non-numerical argument index).
54
+ *
55
+ * This method can also be used as a formatter within a binding. The first part of a composite binding
56
+ * will be used as pattern, the following parts as aValues. If there is only one value and this
57
+ * value is an array it will be handled like the default described above.
58
+ *
59
+ * @function
60
+ * @since 1.58
61
+ * @alias module:sap/base/strings/formatMessage
62
+ * @param {string} sPattern A pattern string in the described syntax
63
+ * @param {any[]} [aValues=[]] The values to be used instead of the placeholders.
64
+ * @returns {string} The formatted result string
65
+ * @SecPassthrough {*|return}
66
+ * @public
67
+ */
3
68
  var fnFormatMessage = function (sPattern, aValues) {
4
- assert(typeof sPattern === 'string' || sPattern instanceof String, 'pattern must be string');
5
- if (arguments.length > 2 || aValues != null && !Array.isArray(aValues)) {
6
- aValues = Array.prototype.slice.call(arguments, 1);
69
+ if (sPattern == null) {
70
+ // Binding formatter case: arguments might be nullish while data is still being populated
71
+ // Return an empty string in those cases
72
+ return "";
73
+ }
74
+ assert(typeof sPattern === "string" || sPattern instanceof String, "pattern must be string");
75
+ if (arguments.length > 2 || aValues != null && !Array.isArray(aValues)) {
76
+ aValues = Array.prototype.slice.call(arguments, 1);
77
+ }
78
+ aValues = aValues || [];
79
+ return sPattern.replace(rMessageFormat, function ($0, $1, $2, $3, offset) {
80
+ if ($1) {
81
+ // a doubled single quote in a normal string fragment
82
+ // --> emit a single quote
83
+ return "'";
84
+ } else if ($2) {
85
+ // a quoted sequence of chars, potentially containing doubled single quotes again
86
+ // --> emit with doubled single quotes replaced by a single quote
87
+ return $2.replace(/''/g, "'");
88
+ } else if ($3) {
89
+ // a welformed curly brace
90
+ // --> emit the argument but ignore other parameters
91
+ return String(aValues[parseInt($3)]);
7
92
  }
8
- aValues = aValues || [];
9
- return sPattern.replace(rMessageFormat, function ($0, $1, $2, $3, offset) {
10
- if ($1) {
11
- return '\'';
12
- } else if ($2) {
13
- return $2.replace(/''/g, '\'');
14
- } else if ($3) {
15
- return String(aValues[parseInt($3)]);
16
- }
17
- throw new Error('formatMessage: pattern syntax error at pos. ' + offset);
18
- });
93
+ // e.g. malformed curly braces
94
+ // --> throw Error
95
+ throw new Error("formatMessage: pattern syntax error at pos. " + offset);
96
+ });
19
97
  };
20
98
  export default fnFormatMessage;
@@ -0,0 +1,4 @@
1
+ declare const LoaderExtensions: {
2
+ loadResource: (moduleName: string) => import("@ui5/webcomponents-base/dist/asset-registries/LocaleData.js").CLDRData;
3
+ };
4
+ export default LoaderExtensions;
@@ -1,7 +1,14 @@
1
- import { getModuleContent } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js";
2
-
1
+ import { getLocaleData } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js";
2
+ const loadResource = (moduleName) => {
3
+ const moduleFormat = moduleName.match(/sap\/ui\/core\/cldr\/(\w+)\.json/);
4
+ if (!moduleFormat) {
5
+ throw new Error(`Unknown module "${moduleName}"`);
6
+ }
7
+ const localeId = moduleFormat[1];
8
+ return getLocaleData(localeId);
9
+ };
3
10
  const LoaderExtensions = {
4
- loadResource: getModuleContent,
11
+ loadResource,
5
12
  };
6
-
7
13
  export default LoaderExtensions;
14
+ //# sourceMappingURL=LoaderExtensions.js.map