@ui5/webcomponents-localization 0.0.0-d9933bd82 → 0.0.0-da0d3eb88

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 (226) hide show
  1. package/.eslintignore +2 -0
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +1284 -0
  4. package/README.md +37 -6
  5. package/dist/.tsbuildinfo +1 -0
  6. package/dist/Assets.d.ts +1 -0
  7. package/dist/Assets.js +1 -0
  8. package/dist/Assets.js.map +1 -0
  9. package/dist/DateFormat.d.ts +6 -0
  10. package/dist/DateFormat.js +6 -2
  11. package/dist/DateFormat.js.map +1 -0
  12. package/dist/LocaleData.d.ts +6 -0
  13. package/dist/LocaleData.js +6 -2
  14. package/dist/LocaleData.js.map +1 -0
  15. package/dist/dates/CalendarDate.d.ts +43 -0
  16. package/dist/dates/CalendarDate.js +171 -181
  17. package/dist/dates/CalendarDate.js.map +1 -0
  18. package/dist/dates/ExtremeDates.d.ts +5 -0
  19. package/dist/dates/ExtremeDates.js +29 -0
  20. package/dist/dates/ExtremeDates.js.map +1 -0
  21. package/dist/dates/UI5Date.d.ts +6 -0
  22. package/dist/dates/UI5Date.js +7 -0
  23. package/dist/dates/UI5Date.js.map +1 -0
  24. package/dist/dates/UniversalDate.d.ts +47 -0
  25. package/dist/dates/UniversalDate.js +5 -0
  26. package/dist/dates/UniversalDate.js.map +1 -0
  27. package/dist/dates/calculateWeekNumber.d.ts +6 -0
  28. package/dist/dates/calculateWeekNumber.js +43 -49
  29. package/dist/dates/calculateWeekNumber.js.map +1 -0
  30. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  31. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  32. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  33. package/dist/dates/getDaysInMonth.d.ts +3 -0
  34. package/dist/dates/getDaysInMonth.js +10 -0
  35. package/dist/dates/getDaysInMonth.js.map +1 -0
  36. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  37. package/dist/dates/getRoundedTimestamp.js +15 -0
  38. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  39. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  40. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  41. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  42. package/dist/dates/modifyDateBy.d.ts +14 -0
  43. package/dist/dates/modifyDateBy.js +55 -0
  44. package/dist/dates/modifyDateBy.js.map +1 -0
  45. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  46. package/dist/dates/transformDateToSecondaryType.js +18 -0
  47. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  48. package/dist/features/calendar/Buddhist.js +1 -0
  49. package/dist/features/calendar/Buddhist.js.map +1 -0
  50. package/dist/features/calendar/Gregorian.js +1 -0
  51. package/dist/features/calendar/Gregorian.js.map +1 -0
  52. package/dist/features/calendar/Islamic.js +1 -0
  53. package/dist/features/calendar/Islamic.js.map +1 -0
  54. package/dist/features/calendar/Japanese.js +1 -0
  55. package/dist/features/calendar/Japanese.js.map +1 -0
  56. package/dist/features/calendar/Persian.js +1 -0
  57. package/dist/features/calendar/Persian.js.map +1 -0
  58. package/dist/generated/assets/cldr/ar.json +5571 -5904
  59. package/dist/generated/assets/cldr/ar_EG.json +5571 -5904
  60. package/dist/generated/assets/cldr/ar_SA.json +5570 -5904
  61. package/dist/generated/assets/cldr/bg.json +4491 -4977
  62. package/dist/generated/assets/cldr/ca.json +4478 -4994
  63. package/dist/generated/assets/cldr/cnr.json +4667 -0
  64. package/dist/generated/assets/cldr/cs.json +5067 -5496
  65. package/dist/generated/assets/cldr/cy.json +5481 -0
  66. package/dist/generated/assets/cldr/da.json +4371 -4886
  67. package/dist/generated/assets/cldr/de.json +4420 -4914
  68. package/dist/generated/assets/cldr/de_AT.json +4421 -4915
  69. package/dist/generated/assets/cldr/de_CH.json +4419 -4913
  70. package/dist/generated/assets/cldr/el.json +4309 -4881
  71. package/dist/generated/assets/cldr/el_CY.json +4309 -4881
  72. package/dist/generated/assets/cldr/en.json +4342 -4968
  73. package/dist/generated/assets/cldr/en_AU.json +4382 -4960
  74. package/dist/generated/assets/cldr/en_GB.json +4373 -4969
  75. package/dist/generated/assets/cldr/en_HK.json +4382 -4975
  76. package/dist/generated/assets/cldr/en_IE.json +4373 -4969
  77. package/dist/generated/assets/cldr/en_IN.json +4378 -4970
  78. package/dist/generated/assets/cldr/en_NZ.json +4373 -4969
  79. package/dist/generated/assets/cldr/en_PG.json +4374 -4970
  80. package/dist/generated/assets/cldr/en_SG.json +4378 -4971
  81. package/dist/generated/assets/cldr/en_ZA.json +4374 -4970
  82. package/dist/generated/assets/cldr/es.json +4584 -4910
  83. package/dist/generated/assets/cldr/es_AR.json +4587 -4912
  84. package/dist/generated/assets/cldr/es_BO.json +4586 -4911
  85. package/dist/generated/assets/cldr/es_CL.json +4479 -4912
  86. package/dist/generated/assets/cldr/es_CO.json +4479 -4911
  87. package/dist/generated/assets/cldr/es_MX.json +4588 -4913
  88. package/dist/generated/assets/cldr/es_PE.json +4370 -4911
  89. package/dist/generated/assets/cldr/es_UY.json +4372 -4913
  90. package/dist/generated/assets/cldr/es_VE.json +4371 -4912
  91. package/dist/generated/assets/cldr/et.json +4373 -4965
  92. package/dist/generated/assets/cldr/fa.json +4429 -4881
  93. package/dist/generated/assets/cldr/fi.json +4514 -5006
  94. package/dist/generated/assets/cldr/fr.json +4383 -4977
  95. package/dist/generated/assets/cldr/fr_BE.json +4383 -4977
  96. package/dist/generated/assets/cldr/fr_CA.json +4377 -4971
  97. package/dist/generated/assets/cldr/fr_CH.json +4401 -4995
  98. package/dist/generated/assets/cldr/fr_LU.json +4383 -4977
  99. package/dist/generated/assets/cldr/he.json +4980 -5376
  100. package/dist/generated/assets/cldr/hi.json +4345 -4827
  101. package/dist/generated/assets/cldr/hr.json +4640 -4917
  102. package/dist/generated/assets/cldr/hu.json +4415 -4854
  103. package/dist/generated/assets/cldr/id.json +4132 -4656
  104. package/dist/generated/assets/cldr/it.json +4355 -4948
  105. package/dist/generated/assets/cldr/it_CH.json +4355 -4948
  106. package/dist/generated/assets/cldr/ja.json +4251 -4828
  107. package/dist/generated/assets/cldr/kk.json +4503 -4723
  108. package/dist/generated/assets/cldr/ko.json +4210 -4736
  109. package/dist/generated/assets/cldr/lt.json +4939 -5479
  110. package/dist/generated/assets/cldr/lv.json +4651 -5110
  111. package/dist/generated/assets/cldr/mk.json +4408 -0
  112. package/dist/generated/assets/cldr/ms.json +4093 -4513
  113. package/dist/generated/assets/cldr/nb.json +4403 -4975
  114. package/dist/generated/assets/cldr/nl.json +4542 -4882
  115. package/dist/generated/assets/cldr/nl_BE.json +4542 -4882
  116. package/dist/generated/assets/cldr/pl.json +4978 -5174
  117. package/dist/generated/assets/cldr/pt.json +4597 -4803
  118. package/dist/generated/assets/cldr/pt_PT.json +4648 -4938
  119. package/dist/generated/assets/cldr/ro.json +4633 -5088
  120. package/dist/generated/assets/cldr/ru.json +4947 -5405
  121. package/dist/generated/assets/cldr/ru_UA.json +4947 -5405
  122. package/dist/generated/assets/cldr/sk.json +4980 -5368
  123. package/dist/generated/assets/cldr/sl.json +4948 -5338
  124. package/dist/generated/assets/cldr/sr.json +4737 -5124
  125. package/dist/generated/assets/cldr/sr_Latn.json +4724 -0
  126. package/dist/generated/assets/cldr/sv.json +4406 -5009
  127. package/dist/generated/assets/cldr/th.json +4234 -4795
  128. package/dist/generated/assets/cldr/tr.json +4451 -4977
  129. package/dist/generated/assets/cldr/uk.json +4908 -5351
  130. package/dist/generated/assets/cldr/vi.json +4094 -4671
  131. package/dist/generated/assets/cldr/zh_CN.json +4124 -4630
  132. package/dist/generated/assets/cldr/zh_HK.json +4132 -4638
  133. package/dist/generated/assets/cldr/zh_SG.json +4132 -4638
  134. package/dist/generated/assets/cldr/zh_TW.json +4155 -4726
  135. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  136. package/dist/generated/json-imports/LocaleData.js +92 -95
  137. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  138. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  139. package/dist/getCachedLocaleDataInstance.js +10 -0
  140. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  141. package/dist/locale/getLocaleData.d.ts +11 -0
  142. package/dist/locale/getLocaleData.js +13 -17
  143. package/dist/locale/getLocaleData.js.map +1 -0
  144. package/dist/sap/base/Event.js +59 -0
  145. package/dist/sap/base/Eventing.js +146 -0
  146. package/dist/sap/base/Log.js +2 -248
  147. package/dist/sap/base/assert.js +31 -9
  148. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  149. package/dist/sap/base/config.js +17 -0
  150. package/dist/sap/base/i18n/Formatting.js +1130 -0
  151. package/dist/sap/base/i18n/LanguageTag.js +173 -0
  152. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  153. package/dist/sap/base/i18n/Localization.js +12 -0
  154. package/dist/sap/base/i18n/Localization.js.map +1 -0
  155. package/dist/sap/base/i18n/date/CalendarType.js +43 -0
  156. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +105 -0
  157. package/dist/sap/base/i18n/date/TimezoneUtils.js +319 -0
  158. package/dist/sap/base/strings/camelize.js +30 -0
  159. package/dist/sap/base/strings/formatMessage.js +88 -15
  160. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  161. package/dist/sap/base/util/LoaderExtensions.js +11 -4
  162. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  163. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  164. package/dist/sap/base/util/ObjectPath.js +4 -33
  165. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  166. package/dist/sap/base/util/Version.js +157 -0
  167. package/dist/sap/base/util/_merge.js +83 -26
  168. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  169. package/dist/sap/base/util/deepClone.js +102 -0
  170. package/dist/sap/base/util/deepEqual.js +75 -55
  171. package/dist/sap/base/util/extend.js +58 -7
  172. package/dist/sap/base/util/isEmptyObject.js +34 -0
  173. package/dist/sap/base/util/isPlainObject.js +35 -1
  174. package/dist/sap/base/util/now.js +24 -3
  175. package/dist/sap/base/util/resolveReference.js +3 -0
  176. package/dist/sap/base/util/uid.js +27 -0
  177. package/dist/sap/ui/base/DataType.js +657 -0
  178. package/dist/sap/ui/base/Interface.js +50 -6
  179. package/dist/sap/ui/base/Metadata.js +435 -173
  180. package/dist/sap/ui/base/Object.js +287 -27
  181. package/dist/sap/ui/core/CalendarType.js +24 -8
  182. package/dist/sap/ui/core/Configuration.d.ts +18 -0
  183. package/dist/sap/ui/core/Configuration.js +23 -0
  184. package/dist/sap/ui/core/Configuration.js.map +1 -0
  185. package/dist/sap/ui/core/Core.d.ts +27 -0
  186. package/dist/sap/ui/core/Core.js +7 -32
  187. package/dist/sap/ui/core/Core.js.map +1 -0
  188. package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
  189. package/dist/sap/ui/core/FormatSettings.js +14 -0
  190. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  191. package/dist/sap/ui/core/Locale.js +190 -116
  192. package/dist/sap/ui/core/LocaleData.js +2668 -2679
  193. package/dist/sap/ui/core/Supportability.js +5 -0
  194. package/dist/sap/ui/core/Theming.js +539 -0
  195. package/dist/sap/ui/core/date/Buddhist.js +162 -93
  196. package/dist/sap/ui/core/date/CalendarUtils.js +65 -0
  197. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  198. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  199. package/dist/sap/ui/core/date/Islamic.js +298 -185
  200. package/dist/sap/ui/core/date/Japanese.js +212 -117
  201. package/dist/sap/ui/core/date/Persian.js +324 -195
  202. package/dist/sap/ui/core/date/UI5Date.js +991 -0
  203. package/dist/sap/ui/core/date/UniversalDate.js +1251 -209
  204. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  205. package/dist/sap/ui/core/format/DateFormat.js +3163 -1781
  206. package/dist/sap/ui/core/format/TimezoneUtil.js +24 -0
  207. package/package-scripts.cjs +28 -0
  208. package/package.json +21 -14
  209. package/tsconfig.json +24 -0
  210. package/used-modules.txt +29 -2
  211. package/dist/sap/ui/Device.js +0 -5
  212. package/package-scripts.js +0 -31
  213. package/src/Assets.js +0 -2
  214. package/src/DateFormat.js +0 -3
  215. package/src/LocaleData.js +0 -3
  216. package/src/dates/CalendarDate.js +0 -203
  217. package/src/dates/calculateWeekNumber.js +0 -51
  218. package/src/locale/getLocaleData.js +0 -27
  219. package/src/sap/base/util/LoaderExtensions.js +0 -7
  220. package/src/sap/ui/core/Core.js +0 -38
  221. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  222. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  223. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  224. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  225. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  226. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -0,0 +1,991 @@
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
+ import Configuration from "../Configuration.js";
7
+ import TimezoneUtil from "../format/TimezoneUtil.js";
8
+ var aAllParts = ["year", "month", "day", "hour", "minute", "second", "fractionalSecond"],
9
+ // "2023", "2023-01", "2023-01-20", "+002023-01-20" are parsed by JavaScript Date as UTC
10
+ // timestamps, whereas "798", "2023-1", "2023-01-5" are parsed as local dates.
11
+ // If "Z", "GMT" or a time zone offset (e.g. 00:00+0530) is included in the input string,
12
+ // the string is parsed as a UTC related timestamp
13
+ rIsUTCString = /Z|GMT|:.*[\+|\-]|^([\+|\-]\d{2})?\d{4}(-\d{2}){0,2}$/,
14
+ aWeekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
15
+ aMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
16
+ mWeekdayToDay = {
17
+ Sun: 0,
18
+ Mon: 1,
19
+ Tue: 2,
20
+ Wed: 3,
21
+ Thu: 4,
22
+ Fri: 5,
23
+ Sat: 6
24
+ };
25
+
26
+ /**
27
+ * Pads the start of the absolute given value with zeros up to the given length. If the given
28
+ * value is negative the leading minus is added in front of the zeros.
29
+ *
30
+ * @param {int} iValue The value to be padded
31
+ * @param {int} iLength The minimal length of the resulting string excluding the minus sign
32
+ * @returns {string} The padded string
33
+ */
34
+ function addLeadingZeros(iValue, iLength) {
35
+ return (iValue < 0 ? "-" : "") + Math.abs(iValue).toString().padStart(iLength, "0");
36
+ }
37
+
38
+ // eslint-disable-next-line valid-jsdoc
39
+ /**
40
+ * DO NOT call the constructor for UI5Date directly; use <code>UI5Date.getInstance</code>.
41
+ *
42
+ * @param {object} vDateParts
43
+ * An array like object containing the arguments as passed to
44
+ * <code>UI5Date.getInstance</code>
45
+ * @param {string} sTimezoneID
46
+ * The time zone ID to use for local methods of <code>Date</code>
47
+ *
48
+ * @alias module:sap/ui/core/date/UI5Date
49
+ * @author SAP SE
50
+ * @extends Date
51
+ * @class A date implementation considering the configured time zone
52
+ *
53
+ * A subclass of JavaScript <code>Date</code> that considers the configured time zone, see
54
+ * {@link sap.ui.core.Configuration#getTimezone}. All JavaScript <code>Date</code> functions
55
+ * that use the local browser time zone, like <code>getDate</code>,
56
+ * <code>setDate</code>, and <code>toString</code>, are overwritten and use the
57
+ * configured time zone to compute the values.
58
+ *
59
+ * Use {@link module:sap/ui/core/date/UI5Date.getInstance} to create new date instances.
60
+ *
61
+ * <b>Note:</b> Adjusting the time zone in a running application can lead to unexpected data
62
+ * inconsistencies. For more information, see {@link sap.ui.core.Configuration#setTimezone}.
63
+ *
64
+ * @hideconstructor
65
+ * @public
66
+ * @since 1.111.0
67
+ * @version 1.120.5
68
+ */
69
+ function UI5Date(vDateParts, sTimezoneID) {
70
+ var oDateInstance = UI5Date._createDateInstance(vDateParts);
71
+ // mark internal properties not enumerable -> deepEqual handles this as a Date instance
72
+ Object.defineProperties(this, {
73
+ sTimezoneID: {
74
+ value: sTimezoneID
75
+ },
76
+ oDate: {
77
+ value: oDateInstance,
78
+ writable: true
79
+ },
80
+ oDateParts: {
81
+ value: undefined,
82
+ writable: true
83
+ }
84
+ });
85
+ if (isNaN(oDateInstance)) {
86
+ return;
87
+ }
88
+ if (vDateParts.length > 1 || vDateParts.length === 1 && typeof vDateParts[0] === "string" && !rIsUTCString.test(vDateParts[0])) {
89
+ this._setParts(aAllParts,
90
+ // JavaScript Date parsed the arguments already in local browser time zone
91
+ [oDateInstance.getFullYear(), oDateInstance.getMonth(), oDateInstance.getDate(), oDateInstance.getHours(), oDateInstance.getMinutes(), oDateInstance.getSeconds(), oDateInstance.getMilliseconds()]);
92
+ }
93
+ }
94
+ UI5Date.prototype = Object.create(Date.prototype, {
95
+ constructor: {
96
+ value: Date
97
+ }
98
+ });
99
+ // QUnit uses Object.prototype.toString.call and expects "[object Date]" for dates; UI5Date
100
+ // shall be treated as a JavaScript Date so Symbol.toStringTag has to be "Date"
101
+ UI5Date.prototype[Symbol.toStringTag] = "Date";
102
+
103
+ /**
104
+ * Returns the value for the requested date part (e.g. "month", "year", "hour") of this date
105
+ * according to the configured time zone.
106
+ *
107
+ * @param {string} sPart The date part name
108
+ * @returns {int} The value of the date part
109
+ *
110
+ * @private
111
+ */
112
+ UI5Date.prototype._getPart = function (sPart) {
113
+ var iResult;
114
+ if (isNaN(this.oDate)) {
115
+ return NaN;
116
+ }
117
+ this.oDateParts = this.oDateParts || TimezoneUtil._getParts(this.oDate, this.sTimezoneID);
118
+ if (sPart === "weekday") {
119
+ return mWeekdayToDay[this.oDateParts.weekday];
120
+ }
121
+ iResult = parseInt(this.oDateParts[sPart]);
122
+ if (sPart === "month") {
123
+ iResult -= 1;
124
+ } else if (sPart === "year") {
125
+ if (this.oDateParts.era === "B") {
126
+ iResult = 1 - iResult;
127
+ }
128
+ }
129
+ return iResult;
130
+ };
131
+
132
+ /**
133
+ * Updates this date instance by setting the given parts in the configured time zone.
134
+ *
135
+ * @param {string[]} aParts
136
+ * The names of the date parts to be updated, supported names are: "year", "month", "day",
137
+ * "hour", "minute", "second", "fractionalSecond"
138
+ * @param {object} aValues
139
+ * The arguments object of the local setters
140
+ * @returns {int}
141
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
142
+ * timestamp could not be created
143
+ *
144
+ * @private
145
+ */
146
+ UI5Date.prototype._setParts = function (aParts, aValues) {
147
+ var i,
148
+ oCurrentDateParts,
149
+ oNewDateAsUTCTimestamp,
150
+ iNewTimestamp,
151
+ sPart,
152
+ vValue,
153
+ oDateParts = {},
154
+ iMaxLength = Math.min(aParts.length, aValues.length);
155
+ if (iMaxLength === 0) {
156
+ return this.setTime(NaN);
157
+ }
158
+ for (i = 0; i < iMaxLength; i += 1) {
159
+ // convert the value to number as JavaScript Date does it;
160
+ // +"" -> 0, +null -> 0, +undefined -> NaN, +"foo" -> NaN, +"4" -> 4
161
+ vValue = parseInt(+aValues[i]);
162
+ sPart = aParts[i];
163
+ if (isNaN(vValue)) {
164
+ return this.setTime(NaN);
165
+ }
166
+ if (sPart === "month") {
167
+ vValue += 1;
168
+ } else if (sPart === "year") {
169
+ if (vValue <= 0) {
170
+ vValue = 1 - vValue;
171
+ oDateParts.era = "B";
172
+ } else {
173
+ oDateParts.era = "A";
174
+ }
175
+ }
176
+ oDateParts[sPart] = vValue.toString();
177
+ }
178
+ if (this.oDateParts) {
179
+ oCurrentDateParts = this.oDateParts;
180
+ } else if (isNaN(this.oDate)) {
181
+ //era and year are given at least
182
+ oCurrentDateParts = {
183
+ day: "1",
184
+ fractionalSecond: "0",
185
+ hour: "0",
186
+ minute: "0",
187
+ month: "1",
188
+ second: "0"
189
+ };
190
+ } else {
191
+ oCurrentDateParts = TimezoneUtil._getParts(this.oDate, this.sTimezoneID);
192
+ }
193
+ oDateParts = Object.assign({}, oCurrentDateParts, oDateParts);
194
+
195
+ // NaN may happen if no year is given if current date is invalid
196
+ oNewDateAsUTCTimestamp = TimezoneUtil._getDateFromParts(oDateParts);
197
+ if (isNaN(oNewDateAsUTCTimestamp)) {
198
+ return this.setTime(NaN);
199
+ }
200
+ iNewTimestamp = oNewDateAsUTCTimestamp.getTime() + TimezoneUtil.calculateOffset(oNewDateAsUTCTimestamp, this.sTimezoneID) * 1000;
201
+ return this.setTime(iNewTimestamp);
202
+ };
203
+
204
+ /**
205
+ * Clones this UI5Date instance.
206
+ *
207
+ * @returns {Date|module:sap/ui/core/date/UI5Date} The cloned date instance
208
+ *
209
+ * @private
210
+ */
211
+ UI5Date.prototype.clone = function () {
212
+ return UI5Date.getInstance(this);
213
+ };
214
+
215
+ /**
216
+ * Returns the day of the month of this date instance according to the configured time zone,
217
+ * see <code>Date.prototype.getDate</code>.
218
+ *
219
+ * @returns {int}
220
+ * A number between 1 and 31 representing the day of the month of this date instance according
221
+ * to the configured time zone
222
+ *
223
+ * @public
224
+ */
225
+ UI5Date.prototype.getDate = function () {
226
+ return this._getPart("day");
227
+ };
228
+
229
+ /**
230
+ * Returns the day of the week of this date instance according to the configured time zone,
231
+ * see <code>Date.prototype.getDay</code>.
232
+ *
233
+ * @returns {int}
234
+ * A number between 0 (Sunday) and 6 (Saturday) representing the day of the week of this date
235
+ * instance according to the configured time zone
236
+ *
237
+ * @public
238
+ */
239
+ UI5Date.prototype.getDay = function () {
240
+ return this._getPart("weekday");
241
+ };
242
+
243
+ /**
244
+ * Returns the year of this date instance according to the configured time zone,
245
+ * see <code>Date.prototype.getFullYear</code>.
246
+ *
247
+ * @returns {int} The year of this date instance according to the configured time zone
248
+ *
249
+ * @public
250
+ */
251
+ UI5Date.prototype.getFullYear = function () {
252
+ return this._getPart("year");
253
+ };
254
+
255
+ /**
256
+ * Returns the hours of this date instance according to the configured time zone, see
257
+ * <code>Date.prototype.getHours</code>.
258
+ *
259
+ * @returns {int}
260
+ * A number between 0 and 23 representing the hours of this date instance according to the
261
+ * configured time zone
262
+ *
263
+ * @public
264
+ */
265
+ UI5Date.prototype.getHours = function () {
266
+ return this._getPart("hour");
267
+ };
268
+
269
+ /**
270
+ * Returns the milliseconds of this date instance according to the configured time zone,
271
+ * see <code>Date.prototype.getMilliseconds</code>.
272
+ *
273
+ * @returns {int}
274
+ * A number between 0 and 999 representing the milliseconds of this date instance according to
275
+ * the configured time zone
276
+ *
277
+ * @public
278
+ */
279
+ UI5Date.prototype.getMilliseconds = function () {
280
+ return this._getPart("fractionalSecond");
281
+ };
282
+
283
+ /**
284
+ * Returns the minutes of this date instance according to the configured time zone,
285
+ * see <code>Date.prototype.getMinutes</code>.
286
+ *
287
+ * @returns {int}
288
+ * A number between 0 and 59 representing the minutes of this date instance according to the
289
+ * configured time zone
290
+ *
291
+ * @public
292
+ */
293
+ UI5Date.prototype.getMinutes = function () {
294
+ return this._getPart("minute");
295
+ };
296
+
297
+ /**
298
+ * Returns the month index of this date instance according to the configured time zone,
299
+ * see <code>Date.prototype.getMonth</code>.
300
+ *
301
+ * @returns {int}
302
+ * The month index between 0 (January) and 11 (December) of this date instance according to
303
+ * the configured time zone
304
+ *
305
+ * @public
306
+ */
307
+ UI5Date.prototype.getMonth = function () {
308
+ return this._getPart("month");
309
+ };
310
+
311
+ /**
312
+ * Returns the seconds of this date instance according to the configured time zone,
313
+ * see <code>Date.prototype.getSeconds</code>.
314
+ *
315
+ * @returns {int}
316
+ * A number between 0 and 59 representing the seconds of this date instance according to the
317
+ * configured time zone
318
+ *
319
+ * @public
320
+ */
321
+ UI5Date.prototype.getSeconds = function () {
322
+ return this._getPart("second");
323
+ };
324
+
325
+ /**
326
+ * Returns the difference in minutes between the UTC and the configured time zone for this date,
327
+ * see <code>Date.prototype.getTimezoneOffset</code>.
328
+ *
329
+ * @returns {int}
330
+ * The difference in minutes between the UTC and the configured time zone for this date
331
+ *
332
+ * @public
333
+ */
334
+ UI5Date.prototype.getTimezoneOffset = function () {
335
+ return TimezoneUtil.calculateOffset(this.oDate, this.sTimezoneID) / 60;
336
+ };
337
+
338
+ /**
339
+ * Returns the year of this date instance minus 1900 according to the configured time zone,
340
+ * see <code>Date.prototype.getYear</code>.
341
+ *
342
+ * @returns {int}
343
+ * The year of this date instance minus 1900 according to the configured time zone
344
+ *
345
+ * @deprecated As of version 1.111 as it is deprecated in the base class JavaScript Date; use
346
+ * {@link #getFullYear} instead
347
+ * @public
348
+ */
349
+ UI5Date.prototype.getYear = function () {
350
+ return this._getPart("year") - 1900;
351
+ };
352
+
353
+ /**
354
+ * Sets the day of the month for this date instance considering the configured time zone,
355
+ * see <code>Date.prototype.setDate</code>.
356
+ *
357
+ * @param {int} iDay
358
+ * An integer representing the new day value, see <code>Date.prototype.setDate</code>
359
+ * @returns {int}
360
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
361
+ * timestamp could not be updated
362
+ *
363
+ * @public
364
+ */
365
+ UI5Date.prototype.setDate = function (iDay) {
366
+ return this._setParts(["day"], arguments);
367
+ };
368
+
369
+ /**
370
+ * Sets the year, month and day for this date instance considering the configured time zone,
371
+ * see <code>Date.prototype.setFullYear</code>.
372
+ *
373
+ * @param {int} iYear An integer representing the new year value
374
+ * @param {int} [iMonth] An integer representing the new month index
375
+ * @param {int} [iDay] An integer representing the new day value
376
+ * @returns {int}
377
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
378
+ * timestamp could not be updated
379
+ *
380
+ * @public
381
+ */
382
+ UI5Date.prototype.setFullYear = function (iYear, iMonth, iDay) {
383
+ return this._setParts(["year", "month", "day"], arguments);
384
+ };
385
+
386
+ /**
387
+ * Sets the hours, minutes, seconds and milliseconds for this date instance considering the
388
+ * configured time zone, see <code>Date.prototype.setHours</code>.
389
+ *
390
+ * @param {int} iHours An integer representing the new hour value
391
+ * @param {int} [iMinutes] An integer representing the new minutes value
392
+ * @param {int} [iSeconds] An integer representing the new seconds value
393
+ * @param {int} [iMilliseconds] An integer representing the new milliseconds value
394
+ * @returns {int}
395
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
396
+ * timestamp could not be updated
397
+ *
398
+ * @public
399
+ */
400
+ UI5Date.prototype.setHours = function (iHours, iMinutes, iSeconds, iMilliseconds) {
401
+ return this._setParts(["hour", "minute", "second", "fractionalSecond"], arguments);
402
+ };
403
+
404
+ /**
405
+ * Sets the milliseconds for this date instance considering the configured time zone, see
406
+ * <code>Date.prototype.setMilliseconds</code>.
407
+ *
408
+ * @param {int} iMilliseconds An integer representing the new milliseconds value
409
+ * @returns {int}
410
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
411
+ * timestamp could not be updated
412
+ *
413
+ * @public
414
+ */
415
+ UI5Date.prototype.setMilliseconds = function (iMilliseconds) {
416
+ return this._setParts(["fractionalSecond"], arguments);
417
+ };
418
+
419
+ /**
420
+ * Sets the minutes, seconds and milliseconds for this date instance considering the configured
421
+ * time zone, see <code>Date.prototype.setMinutes</code>.
422
+ *
423
+ * @param {int} iMinutes An integer representing the new minutes value
424
+ * @param {int} [iSeconds] An integer representing the new seconds value
425
+ * @param {int} [iMilliseconds] An integer representing the new milliseconds value
426
+ * @returns {int}
427
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
428
+ * timestamp could not be updated
429
+ *
430
+ * @public
431
+ */
432
+ UI5Date.prototype.setMinutes = function (iMinutes, iSeconds, iMilliseconds) {
433
+ return this._setParts(["minute", "second", "fractionalSecond"], arguments);
434
+ };
435
+
436
+ /**
437
+ * Sets the month and day for this date instance considering the configured time zone,
438
+ * see <code>Date.prototype.setMonth</code>.
439
+ *
440
+ * @param {int} iMonth An integer representing the new month index
441
+ * @param {int} [iDay] An integer representing the new day value
442
+ * @returns {int}
443
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
444
+ * timestamp could not be updated
445
+ *
446
+ * @public
447
+ */
448
+ UI5Date.prototype.setMonth = function (iMonth, iDay) {
449
+ return this._setParts(["month", "day"], arguments);
450
+ };
451
+
452
+ /**
453
+ * Sets the seconds and milliseconds for this date instance considering the configured time zone,
454
+ * see <code>Date.prototype.setSeconds</code>.
455
+ *
456
+ * @param {int} iSeconds An integer representing the new seconds value
457
+ * @param {int} [iMilliseconds] An integer representing the new milliseconds value
458
+ * @returns {int}
459
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
460
+ * timestamp could not be updated
461
+ *
462
+ * @public
463
+ */
464
+ UI5Date.prototype.setSeconds = function (iSeconds, iMilliseconds) {
465
+ return this._setParts(["second", "fractionalSecond"], arguments);
466
+ };
467
+
468
+ /**
469
+ * Sets this date object to the given time represented by a number of milliseconds based on the
470
+ * UNIX epoch and resets the previously set date parts, see
471
+ * <code>Date.prototype.setTime</code>.
472
+ *
473
+ * @param {int} iTime The date time in milliseconds based in the UNIX epoch
474
+ * @returns {int}
475
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
476
+ * timestamp could not be updated
477
+ *
478
+ * @public
479
+ */
480
+ UI5Date.prototype.setTime = function (iTime) {
481
+ this.oDateParts = undefined;
482
+ return this.oDate.setTime(iTime);
483
+ };
484
+
485
+ /**
486
+ * Sets the year for this date instance plus 1900 considering the configured time zone, see
487
+ * <code>Date.prototype.setYear</code>.
488
+ *
489
+ * @param {int} iYear The year which is to be set for this date. If iYear is a number between 0
490
+ * and 99 (inclusive), then the year for this date is set to 1900 + iYear. Otherwise, the year
491
+ * for this date is set to iYear.
492
+ * @returns {int}
493
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
494
+ * timestamp could not be updated
495
+ *
496
+ * @deprecated As of version 1.111 as it is deprecated in the base class JavaScript Date; use
497
+ * {@link #setFullYear} instead
498
+ * @public
499
+ */
500
+ UI5Date.prototype.setYear = function (iYear) {
501
+ var iValue = parseInt(iYear);
502
+ iValue = iValue < 0 || iValue > 99 ? iValue : iValue + 1900;
503
+ return this._setParts(["year"], [iValue]);
504
+ };
505
+
506
+ /**
507
+ * Returns this date object to the given time represented by a number of milliseconds based on the
508
+ * UNIX epoch, see <code>Date.prototype.getTime</code>.
509
+ *
510
+ * @returns {int}
511
+ * The timestamp in milliseconds of this date based on the UNIX epoch, or <code>NaN</code> if
512
+ * the date is an invalid date
513
+ *
514
+ * @function
515
+ * @name module:sap/ui/core/date/UI5Date.prototype.getTime
516
+ * @public
517
+ */
518
+
519
+ /**
520
+ * Returns the day of the month of this date instance according to universal time,
521
+ * see <code>Date.prototype.getUTCDate</code>.
522
+ *
523
+ * @returns {int}
524
+ * A number between 1 and 31 representing the day of the month of this date instance according
525
+ * to universal time
526
+ *
527
+ * @function
528
+ * @name module:sap/ui/core/date/UI5Date.prototype.getUTCDate
529
+ * @public
530
+ */
531
+
532
+ /**
533
+ *
534
+ * Returns the day of the week of this date instance according to universal time,
535
+ * see <code>Date.prototype.getUTCDay</code>.
536
+ *
537
+ * @returns {int}
538
+ * A number between 0 (Sunday) and 6 (Saturday) representing the day of the week of this date
539
+ * instance according to universal time
540
+ *
541
+ * @function
542
+ * @name module:sap/ui/core/date/UI5Date.prototype.getUTCDay
543
+ * @public
544
+ */
545
+
546
+ /**
547
+ * Returns the year of this date instance according to universal time, see
548
+ * <code>Date.prototype.getUTCFullYear</code>.
549
+ *
550
+ * @returns {int} The year of this date instance according to universal time
551
+ *
552
+ * @function
553
+ * @name module:sap/ui/core/date/UI5Date.prototype.getUTCFullYear
554
+ * @public
555
+ */
556
+
557
+ /**
558
+ * Returns the hours of this date instance according to universal time, see
559
+ * <code>Date.prototype.getUTCHours</code>.
560
+ *
561
+ * @returns {int}
562
+ * A number between 0 and 23 representing the hours of this date instance according to
563
+ * universal time
564
+ *
565
+ * @function
566
+ * @name module:sap/ui/core/date/UI5Date.prototype.getUTCHours
567
+ * @public
568
+ */
569
+
570
+ /**
571
+ * Returns the milliseconds of this date instance according to universal time,
572
+ * see <code>Date.prototype.getUTCMilliseconds</code>.
573
+ *
574
+ * @returns {int}
575
+ * A number between 0 and 999 representing the milliseconds of this date instance according to
576
+ * universal time
577
+ *
578
+ * @function
579
+ * @name module:sap/ui/core/date/UI5Date.prototype.getUTCMilliseconds
580
+ * @public
581
+ */
582
+
583
+ /**
584
+ * Returns the minutes of this date instance according to universal time, see
585
+ * <code>Date.prototype.getUTCMinutes</code>.
586
+ *
587
+ * @returns {int}
588
+ * A number between 0 and 59 representing the minutes of this date instance according to
589
+ * universal time
590
+ *
591
+ * @function
592
+ * @name module:sap/ui/core/date/UI5Date.prototype.getUTCMinutes
593
+ * @public
594
+ */
595
+
596
+ /**
597
+ * Returns the month index of this date instance according to universal time, see
598
+ * <code>Date.prototype.getUTCMonth</code>.
599
+ *
600
+ * @returns {int}
601
+ * The month index between 0 (January) and 11 (December) of this date instance according to
602
+ * universal time
603
+ *
604
+ * @function
605
+ * @name module:sap/ui/core/date/UI5Date.prototype.getUTCMonth
606
+ * @public
607
+ */
608
+
609
+ /**
610
+ * Returns the seconds of this date instance according to universal time, see
611
+ * <code>Date.prototype.getUTCSeconds</code>.
612
+ *
613
+ * @returns {int}
614
+ * A number between 0 and 59 representing the seconds of this date instance according to
615
+ * universal time
616
+ *
617
+ * @function
618
+ * @name module:sap/ui/core/date/UI5Date.prototype.getUTCSeconds
619
+ * @public
620
+ */
621
+
622
+ /**
623
+ * Sets the day of the month for this date instance according to universal time,
624
+ * see <code>Date.prototype.setUTCDate</code>.
625
+ *
626
+ * @param {int} iDay
627
+ * An integer representing the new day value, see <code>Date.prototype.setUTCDate</code>
628
+ * @returns {int}
629
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
630
+ * timestamp could not be updated
631
+ *
632
+ * @function
633
+ * @name module:sap/ui/core/date/UI5Date.prototype.setUTCDate
634
+ * @public
635
+ */
636
+
637
+ /**
638
+ * Sets the year, month and day for this date instance according to universal time,
639
+ * see <code>Date.prototype.setUTCFullYear</code>.
640
+ *
641
+ * @param {int} iYear An integer representing the new year value
642
+ * @param {int} [iMonth] An integer representing the new month index
643
+ * @param {int} [iDay] An integer representing the new day value
644
+ * @returns {int}
645
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
646
+ * timestamp could not be updated
647
+ *
648
+ * @function
649
+ * @name module:sap/ui/core/date/UI5Date.prototype.setUTCFullYear
650
+ * @public
651
+ */
652
+
653
+ /**
654
+ * Sets the hours, minutes, seconds and milliseconds for this date instance according to
655
+ * universal time, see <code>Date.prototype.setUTCHours</code>.
656
+ *
657
+ * @param {int} iHours An integer representing the new hour value
658
+ * @param {int} [iMinutes] An integer representing the new minutes value
659
+ * @param {int} [iSeconds] An integer representing the new seconds value
660
+ * @param {int} [iMilliseconds] An integer representing the new milliseconds value
661
+ * @returns {int}
662
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
663
+ * timestamp could not be updated
664
+ *
665
+ * @function
666
+ * @name module:sap/ui/core/date/UI5Date.prototype.setUTCHours
667
+ * @public
668
+ */
669
+
670
+ /**
671
+ * Sets the milliseconds for this date instance according to universal time, see
672
+ * <code>Date.prototype.setUTCMilliseconds</code>.
673
+ *
674
+ * @param {int} iMilliseconds An integer representing the new milliseconds value
675
+ * @returns {int}
676
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
677
+ * timestamp could not be updated
678
+ *
679
+ * @function
680
+ * @name module:sap/ui/core/date/UI5Date.prototype.setUTCMilliseconds
681
+ * @public
682
+ */
683
+
684
+ /**
685
+ * Sets the minutes, seconds and milliseconds for this date instance according to universal
686
+ * time, see <code>Date.prototype.setUTCMinutes</code>.
687
+ *
688
+ * @param {int} iMinutes An integer representing the new minutes value
689
+ * @param {int} [iSeconds] An integer representing the new seconds value
690
+ * @param {int} [iMilliseconds] An integer representing the new milliseconds value
691
+ * @returns {int}
692
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
693
+ * timestamp could not be updated
694
+ *
695
+ * @function
696
+ * @name module:sap/ui/core/date/UI5Date.prototype.setUTCMinutes
697
+ * @public
698
+ */
699
+
700
+ /**
701
+ * Sets the month and day for this date instance according to universal time,
702
+ * see <code>Date.prototype.setUTCMonth</code>.
703
+ *
704
+ * @param {int} iMonth An integer representing the new month index
705
+ * @param {int} [iDay] An integer representing the new day value
706
+ * @returns {int}
707
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
708
+ * timestamp could not be updated
709
+ *
710
+ * @function
711
+ * @name module:sap/ui/core/date/UI5Date.prototype.setUTCMonth
712
+ * @public
713
+ */
714
+
715
+ /**
716
+ * Sets the seconds and milliseconds for this date instance according to universal time,
717
+ * see <code>Date.prototype.setUTCSeconds</code>.
718
+ *
719
+ * @param {int} iSeconds An integer representing the new seconds value
720
+ * @param {int} [iMilliseconds] An integer representing the new milliseconds value
721
+ * @returns {int}
722
+ * The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
723
+ * timestamp could not be updated
724
+ *
725
+ * @function
726
+ * @name module:sap/ui/core/date/UI5Date.prototype.setUTCSeconds
727
+ * @public
728
+ */
729
+
730
+ /**
731
+ * Converts this date to a string, interpreting it in the UTC time zone, see
732
+ * <code>Date.prototype.toGMTString</code>.
733
+ *
734
+ * @returns {string} The converted date as string in the UTC time zone
735
+ *
736
+ * @function
737
+ * @name module:sap/ui/core/date/UI5Date.prototype.toGMTString
738
+ * @public
739
+ */
740
+
741
+ /**
742
+ * Converts this date to a string in ISO format in the UTC offset zero time zone, as denoted
743
+ * by the suffix <code>Z</code>, see <code>Date.prototype.toISOString</code>.
744
+ *
745
+ * @returns {string}
746
+ * The converted date as a string in ISO format, in the UTC offset zero time zone
747
+ *
748
+ * @function
749
+ * @name module:sap/ui/core/date/UI5Date.prototype.toISOString
750
+ * @public
751
+ */
752
+
753
+ /**
754
+ * Returns a string representation of this date object, see <code>Date.prototype.toJSON</code>.
755
+ *
756
+ * @returns {string} The date object representation as a string
757
+ *
758
+ * @function
759
+ * @name module:sap/ui/core/date/UI5Date.prototype.toJSON
760
+ * @public
761
+ */
762
+
763
+ /**
764
+ * Returns the date portion of this date object interpreted in the configured time zone in
765
+ * English, see <code>Date.prototype.toDateString</code>.
766
+ *
767
+ * @returns {string}
768
+ * The date portion of this date object interpreted in the configured time zone in English
769
+ *
770
+ * @public
771
+ */
772
+ UI5Date.prototype.toDateString = function () {
773
+ if (isNaN(this.oDate)) {
774
+ return this.oDate.toDateString();
775
+ }
776
+ return aWeekday[this.getDay()] + " " + aMonths[this.getMonth()] + " " + addLeadingZeros(this.getDate(), 2) + " " + addLeadingZeros(this.getFullYear(), 4);
777
+ };
778
+
779
+ /**
780
+ * Returns a string with a language-dependent representation of the date part of this date
781
+ * object interpreted by default in the configured time zone, see
782
+ * <code>Date.prototype.toLocaleDateString</code>.
783
+ *
784
+ * @param {string} [sLocale=sap.ui.core.Configuration.getLanguageTag()]
785
+ * The locale used for formatting; the configured locale by default
786
+ * @param {object} [oOptions]
787
+ * The options object used for formatting, corresponding to the options parameter of the
788
+ * <code>Intl.DateTimeFormat</code> constructor
789
+ * @param {string} [oOptions.timeZone=sap.ui.core.Configuration.getTimezone()]
790
+ * The IANA time zone ID; the configured time zone by default
791
+ * @returns {string}
792
+ * The language-dependent representation of the date part of this date object
793
+ *
794
+ * @function
795
+ * @name module:sap/ui/core/date/UI5Date.prototype.toLocaleDateString
796
+ * @public
797
+ */
798
+
799
+ /**
800
+ * Returns a string with a language-dependent representation of this date object interpreted by
801
+ * default in the configured time zone, see <code>Date.prototype.toLocaleString</code>.
802
+ *
803
+ * @param {string} [sLocale=sap.ui.core.Configuration.getLanguageTag()]
804
+ * The locale used for formatting; the configured locale by default
805
+ * @param {object} [oOptions]
806
+ * The options object used for formatting, corresponding to the options parameter of the
807
+ * <code>Intl.DateTimeFormat</code> constructor
808
+ * @param {string} [oOptions.timeZone=sap.ui.core.Configuration.getTimezone()]
809
+ * The IANA time zone ID; the configured time zone by default
810
+ * @returns {string}
811
+ * The language-dependent representation of this date object
812
+ *
813
+ * @function
814
+ * @name module:sap/ui/core/date/UI5Date.prototype.toLocaleString
815
+ * @public
816
+ */
817
+
818
+ /**
819
+ * Returns a string with a language-dependent representation of the time part of this date
820
+ * object interpreted by default in the configured time zone, see
821
+ * <code>Date.prototype.toLocaleTimeString</code>.
822
+ *
823
+ * @param {string} [sLocale=sap.ui.core.Configuration.getLanguageTag()]
824
+ * The locale used for formatting; the configured locale by default
825
+ * @param {object} [oOptions]
826
+ * The options object used for formatting, corresponding to the options parameter of the
827
+ * <code>Intl.DateTimeFormat</code> constructor
828
+ * @param {string} [oOptions.timeZone=sap.ui.core.Configuration.getTimezone()]
829
+ * The IANA time zone ID; the configured time zone by default
830
+ * @returns {string}
831
+ * The language-dependent representation of the time part of this date object
832
+ *
833
+ * @function
834
+ * @name module:sap/ui/core/date/UI5Date.prototype.toLocaleTimeString
835
+ * @public
836
+ */
837
+
838
+ /**
839
+ * Returns a string representing this date object interpreted in the configured time zone.
840
+ *
841
+ * @returns {string}
842
+ * A string representing this date object interpreted in the configured time zone
843
+ *
844
+ * @public
845
+ */
846
+ UI5Date.prototype.toString = function () {
847
+ if (isNaN(this.oDate)) {
848
+ return this.oDate.toString();
849
+ }
850
+ return this.toDateString() + " " + this.toTimeString();
851
+ };
852
+
853
+ /**
854
+ * Returns the time portion of this date object interpreted in the configured time zone in English.
855
+ *
856
+ * @returns {string}
857
+ * The time portion of this date object interpreted in the configured time zone in English
858
+ *
859
+ * @public
860
+ */
861
+ UI5Date.prototype.toTimeString = function () {
862
+ var iHours, iMinutes, sSign, iTimeZoneOffset;
863
+ if (isNaN(this.oDate)) {
864
+ return this.oDate.toTimeString();
865
+ }
866
+ iTimeZoneOffset = this.getTimezoneOffset();
867
+ sSign = iTimeZoneOffset > 0 ? "-" : "+";
868
+ iHours = Math.floor(Math.abs(iTimeZoneOffset) / 60);
869
+ iMinutes = Math.abs(iTimeZoneOffset) % 60;
870
+
871
+ // ommit the optional, implementation dependent time zone name
872
+ return addLeadingZeros(this.getHours(), 2) + ":" + addLeadingZeros(this.getMinutes(), 2) + ":" + addLeadingZeros(this.getSeconds(), 2) + " GMT" + sSign + addLeadingZeros(iHours, 2) + addLeadingZeros(iMinutes, 2);
873
+ };
874
+
875
+ /**
876
+ * Converts this date to a string, interpreting it in the UTC time zone, see
877
+ * <code>Date.prototype.toUTCString</code>.
878
+ *
879
+ * @returns {string} The converted date as a string in the UTC time zone
880
+ *
881
+ * @function
882
+ * @name module:sap/ui/core/date/UI5Date.prototype.toUTCString
883
+ * @public
884
+ */
885
+
886
+ /**
887
+ * Returns the value of this date object in milliseconds based on the UNIX epoch, see
888
+ * <code>Date.prototype.valueOf</code>.
889
+ *
890
+ * @returns {int} The primitive value of this date object in milliseconds based on the UNIX epoch
891
+ *
892
+ * @function
893
+ * @name module:sap/ui/core/date/UI5Date.prototype.valueOf
894
+ * @public
895
+ */
896
+
897
+ // functions that simply delegate to the inner date instance
898
+ ["getTime", "getUTCDate", "getUTCDay", "getUTCFullYear", "getUTCHours", "getUTCMilliseconds", "getUTCMinutes", "getUTCMonth", "getUTCSeconds", "toGMTString", "toISOString", "toJSON", "toUTCString", "valueOf"].forEach(function (sMethod) {
899
+ UI5Date.prototype[sMethod] = function () {
900
+ return this.oDate[sMethod].apply(this.oDate, arguments);
901
+ };
902
+ });
903
+ ["toLocaleDateString", "toLocaleString", "toLocaleTimeString"].forEach(function (sMethod) {
904
+ UI5Date.prototype[sMethod] = function (sLocale, oOptions) {
905
+ return this.oDate[sMethod](sLocale || Configuration.getLanguageTag(), Object.assign({
906
+ timeZone: this.sTimezoneID
907
+ }, oOptions));
908
+ };
909
+ });
910
+
911
+ // before delegating to the inner date instance clear the cached date parts
912
+ ["setUTCDate", "setUTCFullYear", "setUTCHours", "setUTCMilliseconds", "setUTCMinutes", "setUTCMonth", "setUTCSeconds"].forEach(function (sMethod) {
913
+ UI5Date.prototype[sMethod] = function () {
914
+ this.oDateParts = undefined;
915
+ return this.oDate[sMethod].apply(this.oDate, arguments);
916
+ };
917
+ });
918
+
919
+ /**
920
+ * Creates a JavaScript Date instance.
921
+ *
922
+ * @param {object} vParts
923
+ * The <code>arguments</code> object which is given to
924
+ * <code>module:sap/ui/core/date/UI5Date.getInstance</code>
925
+ * @returns {Date}
926
+ * A JavaScript Date instance
927
+ *
928
+ * @private
929
+ */
930
+ UI5Date._createDateInstance = function (vParts) {
931
+ if (vParts[0] instanceof Date) {
932
+ vParts[0] = vParts[0].valueOf();
933
+ }
934
+
935
+ // ES5 variant of new Date(...vParts)
936
+ return new (Function.prototype.bind.apply(Date, [].concat.apply([null], vParts)))();
937
+ };
938
+
939
+ /**
940
+ * Creates a date instance (either JavaScript Date or <code>UI5Date</code>) which considers the
941
+ * configured time zone wherever JavaScript Date uses the local browser time zone, for example
942
+ * in <code>getDate</code>, <code>toString</code>, or <code>setHours</code>. The supported
943
+ * parameters are the same as the ones supported by the JavaScript Date constructor.
944
+ *
945
+ * <b>Note:</b> Adjusting the time zone in a running application can lead to unexpected data
946
+ * inconsistencies. For more information, see {@link sap.ui.core.Configuration#setTimezone}.
947
+ *
948
+ * @param {int|string|Date|module:sap/ui/core/date/UI5Date|null} [vYearOrValue]
949
+ * Same meaning as in the JavaScript Date constructor
950
+ * @param {int|string} [vMonthIndex]
951
+ * Same meaning as in the JavaScript Date constructor
952
+ * @param {int|string} [vDay=1] Same meaning as in the JavaScript Date constructor
953
+ * @param {int|string} [vHours=0] Same meaning as in the JavaScript Date constructor
954
+ * @param {int|string} [vMinutes=0] Same meaning as in the JavaScript Date constructor
955
+ * @param {int|string} [vSeconds=0] Same meaning as in the JavaScript Date constructor
956
+ * @param {int|string} [vMilliseconds=0] Same meaning as in the JavaScript Date constructor
957
+ * @returns {Date|module:sap/ui/core/date/UI5Date}
958
+ * The date instance that considers the configured time zone in all local getters and setters.
959
+ *
960
+ * @public
961
+ * @see sap.ui.core.Configuration#getTimezone
962
+ */
963
+ UI5Date.getInstance = function () {
964
+ var sTimezone = Configuration.getTimezone();
965
+ if (sTimezone !== TimezoneUtil.getLocalTimezone()) {
966
+ return new UI5Date(arguments, sTimezone);
967
+ }
968
+ // time zones are equal -> use JavaScript Date as it is
969
+ return UI5Date._createDateInstance(arguments);
970
+ };
971
+
972
+ /**
973
+ * Checks whether the given date object is a valid date, considers the configured time zone
974
+ * and throws an error otherwise.
975
+ *
976
+ * @param {Date|module:sap/ui/core/date/UI5Date} oDate
977
+ * The date object created via <code>UI5Date.getInstance</code>
978
+ * @throws {Error}
979
+ * If the given date object is not valid or does not consider the configured time zone
980
+ *
981
+ * @private
982
+ */
983
+ UI5Date.checkDate = function (oDate) {
984
+ if (isNaN(oDate.getTime())) {
985
+ throw new Error("The given Date is not valid");
986
+ }
987
+ if (!(oDate instanceof UI5Date) && Configuration.getTimezone() !== TimezoneUtil.getLocalTimezone()) {
988
+ throw new Error("Configured time zone requires the parameter 'oDate' to be an instance of" + " sap.ui.core.date.UI5Date");
989
+ }
990
+ };
991
+ export default UI5Date;