@ui5/webcomponents-localization 0.0.0-d9b978d1d → 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 (217) hide show
  1. package/CHANGELOG.md +469 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/dates/calculateWeekNumber.d.ts +2 -1
  4. package/dist/dates/calculateWeekNumber.js +6 -6
  5. package/dist/dates/calculateWeekNumber.js.map +1 -1
  6. package/dist/generated/assets/cldr/ar.json +102 -62
  7. package/dist/generated/assets/cldr/ar_EG.json +102 -62
  8. package/dist/generated/assets/cldr/ar_SA.json +102 -62
  9. package/dist/generated/assets/cldr/bg.json +364 -325
  10. package/dist/generated/assets/cldr/ca.json +491 -453
  11. package/{src/generated/assets/cldr/sr_Latn.json → dist/generated/assets/cldr/cnr.json} +471 -380
  12. package/dist/generated/assets/cldr/cs.json +431 -324
  13. package/dist/generated/assets/cldr/cy.json +608 -340
  14. package/dist/generated/assets/cldr/da.json +290 -227
  15. package/dist/generated/assets/cldr/de.json +348 -241
  16. package/dist/generated/assets/cldr/de_AT.json +348 -241
  17. package/dist/generated/assets/cldr/de_CH.json +347 -240
  18. package/dist/generated/assets/cldr/el.json +128 -100
  19. package/dist/generated/assets/cldr/el_CY.json +128 -100
  20. package/dist/generated/assets/cldr/en.json +538 -512
  21. package/dist/generated/assets/cldr/en_AU.json +583 -520
  22. package/dist/generated/assets/cldr/en_GB.json +485 -441
  23. package/dist/generated/assets/cldr/en_HK.json +519 -474
  24. package/dist/generated/assets/cldr/en_IE.json +485 -440
  25. package/dist/generated/assets/cldr/en_IN.json +465 -420
  26. package/dist/generated/assets/cldr/en_NZ.json +505 -460
  27. package/dist/generated/assets/cldr/en_PG.json +505 -460
  28. package/dist/generated/assets/cldr/en_SG.json +505 -460
  29. package/dist/generated/assets/cldr/en_ZA.json +485 -440
  30. package/dist/generated/assets/cldr/es.json +709 -456
  31. package/dist/generated/assets/cldr/es_AR.json +687 -434
  32. package/dist/generated/assets/cldr/es_BO.json +721 -468
  33. package/dist/generated/assets/cldr/es_CL.json +567 -422
  34. package/dist/generated/assets/cldr/es_CO.json +485 -339
  35. package/dist/generated/assets/cldr/es_MX.json +734 -481
  36. package/dist/generated/assets/cldr/es_PE.json +409 -372
  37. package/dist/generated/assets/cldr/es_UY.json +433 -396
  38. package/dist/generated/assets/cldr/es_VE.json +453 -416
  39. package/dist/generated/assets/cldr/et.json +340 -307
  40. package/dist/generated/assets/cldr/fa.json +96 -34
  41. package/dist/generated/assets/cldr/fi.json +359 -308
  42. package/dist/generated/assets/cldr/fr.json +347 -321
  43. package/dist/generated/assets/cldr/fr_BE.json +347 -321
  44. package/dist/generated/assets/cldr/fr_CA.json +458 -432
  45. package/dist/generated/assets/cldr/fr_CH.json +290 -264
  46. package/dist/generated/assets/cldr/fr_LU.json +347 -321
  47. package/dist/generated/assets/cldr/he.json +241 -130
  48. package/dist/generated/assets/cldr/hi.json +103 -53
  49. package/dist/generated/assets/cldr/hr.json +467 -410
  50. package/dist/generated/assets/cldr/hu.json +246 -195
  51. package/dist/generated/assets/cldr/id.json +478 -406
  52. package/dist/generated/assets/cldr/it.json +418 -362
  53. package/dist/generated/assets/cldr/it_CH.json +418 -362
  54. package/dist/generated/assets/cldr/ja.json +58 -18
  55. package/dist/generated/assets/cldr/kk.json +562 -398
  56. package/dist/generated/assets/cldr/ko.json +36 -15
  57. package/dist/generated/assets/cldr/lt.json +320 -231
  58. package/dist/generated/assets/cldr/lv.json +184 -120
  59. package/dist/generated/assets/cldr/mk.json +4408 -0
  60. package/dist/generated/assets/cldr/ms.json +460 -388
  61. package/dist/generated/assets/cldr/nb.json +160 -92
  62. package/dist/generated/assets/cldr/nl.json +621 -373
  63. package/dist/generated/assets/cldr/nl_BE.json +621 -373
  64. package/dist/generated/assets/cldr/pl.json +590 -279
  65. package/dist/generated/assets/cldr/pt.json +696 -334
  66. package/dist/generated/assets/cldr/pt_PT.json +730 -454
  67. package/dist/generated/assets/cldr/ro.json +409 -339
  68. package/dist/generated/assets/cldr/ru.json +317 -279
  69. package/dist/generated/assets/cldr/ru_UA.json +312 -274
  70. package/dist/generated/assets/cldr/sk.json +454 -413
  71. package/dist/generated/assets/cldr/sl.json +118 -80
  72. package/dist/generated/assets/cldr/sr.json +294 -142
  73. package/dist/generated/assets/cldr/sr_Latn.json +972 -824
  74. package/dist/generated/assets/cldr/sv.json +382 -338
  75. package/dist/generated/assets/cldr/th.json +56 -36
  76. package/dist/generated/assets/cldr/tr.json +371 -320
  77. package/dist/generated/assets/cldr/uk.json +340 -290
  78. package/dist/generated/assets/cldr/vi.json +352 -328
  79. package/dist/generated/assets/cldr/zh_CN.json +34 -10
  80. package/dist/generated/assets/cldr/zh_HK.json +33 -9
  81. package/dist/generated/assets/cldr/zh_SG.json +33 -9
  82. package/dist/generated/assets/cldr/zh_TW.json +52 -28
  83. package/dist/generated/json-imports/LocaleData.js +4 -2
  84. package/dist/generated/json-imports/LocaleData.js.map +1 -1
  85. package/dist/sap/base/Event.js +59 -0
  86. package/dist/sap/base/Eventing.js +146 -0
  87. package/dist/sap/base/Log.js +2 -239
  88. package/dist/sap/base/assert.js +28 -1
  89. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  90. package/dist/sap/base/config.js +17 -0
  91. package/dist/sap/base/i18n/Formatting.js +1130 -0
  92. package/dist/sap/base/i18n/LanguageTag.js +168 -30
  93. package/dist/sap/base/i18n/date/CalendarType.js +36 -1
  94. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +76 -1
  95. package/dist/sap/base/i18n/date/TimezoneUtils.js +242 -12
  96. package/dist/sap/base/strings/camelize.js +30 -0
  97. package/dist/sap/base/strings/formatMessage.js +88 -15
  98. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  99. package/dist/sap/base/util/ObjectPath.js +4 -33
  100. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  101. package/dist/sap/base/util/Version.js +157 -0
  102. package/dist/sap/base/util/_merge.js +83 -26
  103. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  104. package/dist/sap/base/util/deepClone.js +102 -0
  105. package/dist/sap/base/util/deepEqual.js +75 -51
  106. package/dist/sap/base/util/extend.js +58 -7
  107. package/dist/sap/base/util/isEmptyObject.js +34 -0
  108. package/dist/sap/base/util/isPlainObject.js +35 -1
  109. package/dist/sap/base/util/now.js +24 -3
  110. package/dist/sap/base/util/resolveReference.js +3 -0
  111. package/dist/sap/base/util/uid.js +27 -0
  112. package/dist/sap/ui/base/DataType.js +657 -0
  113. package/dist/sap/ui/base/Interface.js +47 -1
  114. package/dist/sap/ui/base/Metadata.js +433 -180
  115. package/dist/sap/ui/base/Object.js +284 -48
  116. package/dist/sap/ui/core/CalendarType.js +23 -1
  117. package/dist/sap/ui/core/Locale.js +189 -57
  118. package/dist/sap/ui/core/LocaleData.js +2670 -1380
  119. package/dist/sap/ui/core/Supportability.js +5 -0
  120. package/dist/sap/ui/core/Theming.js +539 -0
  121. package/dist/sap/ui/core/date/Buddhist.js +162 -87
  122. package/dist/sap/ui/core/date/CalendarUtils.js +61 -21
  123. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +29 -1
  124. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  125. package/dist/sap/ui/core/date/Islamic.js +298 -185
  126. package/dist/sap/ui/core/date/Japanese.js +210 -115
  127. package/dist/sap/ui/core/date/Persian.js +324 -195
  128. package/dist/sap/ui/core/date/UI5Date.js +923 -237
  129. package/dist/sap/ui/core/date/UniversalDate.js +1238 -245
  130. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  131. package/dist/sap/ui/core/format/DateFormat.js +3163 -2145
  132. package/dist/sap/ui/core/format/TimezoneUtil.js +23 -1
  133. package/package-scripts.cjs +7 -11
  134. package/package.json +11 -6
  135. package/tsconfig.json +2 -1
  136. package/used-modules.txt +20 -1
  137. package/dist/Assets-static.d.ts +0 -1
  138. package/dist/Assets-static.js +0 -3
  139. package/dist/Assets-static.js.map +0 -1
  140. package/dist/generated/json-imports/LocaleData-static.d.ts +0 -1
  141. package/dist/generated/json-imports/LocaleData-static.js +0 -88
  142. package/dist/generated/json-imports/LocaleData-static.js.map +0 -1
  143. package/dist/sap/ui/Device.js +0 -5
  144. package/src/generated/assets/cldr/ar.json +0 -5533
  145. package/src/generated/assets/cldr/ar_EG.json +0 -5533
  146. package/src/generated/assets/cldr/ar_SA.json +0 -5532
  147. package/src/generated/assets/cldr/bg.json +0 -4454
  148. package/src/generated/assets/cldr/ca.json +0 -4442
  149. package/src/generated/assets/cldr/cs.json +0 -4962
  150. package/src/generated/assets/cldr/cy.json +0 -5213
  151. package/src/generated/assets/cldr/da.json +0 -4310
  152. package/src/generated/assets/cldr/de.json +0 -4315
  153. package/src/generated/assets/cldr/de_AT.json +0 -4316
  154. package/src/generated/assets/cldr/de_CH.json +0 -4314
  155. package/src/generated/assets/cldr/el.json +0 -4283
  156. package/src/generated/assets/cldr/el_CY.json +0 -4283
  157. package/src/generated/assets/cldr/en.json +0 -4318
  158. package/src/generated/assets/cldr/en_AU.json +0 -4321
  159. package/src/generated/assets/cldr/en_GB.json +0 -4331
  160. package/src/generated/assets/cldr/en_HK.json +0 -4339
  161. package/src/generated/assets/cldr/en_IE.json +0 -4330
  162. package/src/generated/assets/cldr/en_IN.json +0 -4335
  163. package/src/generated/assets/cldr/en_NZ.json +0 -4330
  164. package/src/generated/assets/cldr/en_PG.json +0 -4331
  165. package/src/generated/assets/cldr/en_SG.json +0 -4335
  166. package/src/generated/assets/cldr/en_ZA.json +0 -4331
  167. package/src/generated/assets/cldr/es.json +0 -4333
  168. package/src/generated/assets/cldr/es_AR.json +0 -4336
  169. package/src/generated/assets/cldr/es_BO.json +0 -4335
  170. package/src/generated/assets/cldr/es_CL.json +0 -4336
  171. package/src/generated/assets/cldr/es_CO.json +0 -4335
  172. package/src/generated/assets/cldr/es_MX.json +0 -4337
  173. package/src/generated/assets/cldr/es_PE.json +0 -4335
  174. package/src/generated/assets/cldr/es_UY.json +0 -4337
  175. package/src/generated/assets/cldr/es_VE.json +0 -4336
  176. package/src/generated/assets/cldr/et.json +0 -4342
  177. package/src/generated/assets/cldr/fa.json +0 -4369
  178. package/src/generated/assets/cldr/fi.json +0 -4465
  179. package/src/generated/assets/cldr/fr.json +0 -4359
  180. package/src/generated/assets/cldr/fr_BE.json +0 -4359
  181. package/src/generated/assets/cldr/fr_CA.json +0 -4353
  182. package/src/generated/assets/cldr/fr_CH.json +0 -4377
  183. package/src/generated/assets/cldr/fr_LU.json +0 -4359
  184. package/src/generated/assets/cldr/he.json +0 -4871
  185. package/src/generated/assets/cldr/hi.json +0 -4297
  186. package/src/generated/assets/cldr/hr.json +0 -4585
  187. package/src/generated/assets/cldr/hu.json +0 -4366
  188. package/src/generated/assets/cldr/id.json +0 -4062
  189. package/src/generated/assets/cldr/it.json +0 -4301
  190. package/src/generated/assets/cldr/it_CH.json +0 -4301
  191. package/src/generated/assets/cldr/ja.json +0 -4213
  192. package/src/generated/assets/cldr/kk.json +0 -4341
  193. package/src/generated/assets/cldr/ko.json +0 -4191
  194. package/src/generated/assets/cldr/lt.json +0 -4852
  195. package/src/generated/assets/cldr/lv.json +0 -4589
  196. package/src/generated/assets/cldr/ms.json +0 -4023
  197. package/src/generated/assets/cldr/nb.json +0 -4337
  198. package/src/generated/assets/cldr/nl.json +0 -4296
  199. package/src/generated/assets/cldr/nl_BE.json +0 -4296
  200. package/src/generated/assets/cldr/pl.json +0 -4669
  201. package/src/generated/assets/cldr/pt.json +0 -4237
  202. package/src/generated/assets/cldr/pt_PT.json +0 -4374
  203. package/src/generated/assets/cldr/ro.json +0 -4565
  204. package/src/generated/assets/cldr/ru.json +0 -4911
  205. package/src/generated/assets/cldr/ru_UA.json +0 -4911
  206. package/src/generated/assets/cldr/sk.json +0 -4941
  207. package/src/generated/assets/cldr/sl.json +0 -4912
  208. package/src/generated/assets/cldr/sr.json +0 -4587
  209. package/src/generated/assets/cldr/sv.json +0 -4364
  210. package/src/generated/assets/cldr/th.json +0 -4216
  211. package/src/generated/assets/cldr/tr.json +0 -4402
  212. package/src/generated/assets/cldr/uk.json +0 -4860
  213. package/src/generated/assets/cldr/vi.json +0 -4072
  214. package/src/generated/assets/cldr/zh_CN.json +0 -4102
  215. package/src/generated/assets/cldr/zh_HK.json +0 -4110
  216. package/src/generated/assets/cldr/zh_SG.json +0 -4110
  217. package/src/generated/assets/cldr/zh_TW.json +0 -4133
@@ -1,305 +1,991 @@
1
- import Configuration from '../Configuration.js';
2
- import TimezoneUtil from '../format/TimezoneUtil.js';
3
- var aAllParts = [
4
- 'year',
5
- 'month',
6
- 'day',
7
- 'hour',
8
- 'minute',
9
- 'second',
10
- 'fractionalSecond'
11
- ], rIsUTCString = /Z|GMT|:.*[\+|\-]|^([\+|\-]\d{2})?\d{4}(-\d{2}){0,2}$/, aWeekday = [
12
- 'Sun',
13
- 'Mon',
14
- 'Tue',
15
- 'Wed',
16
- 'Thu',
17
- 'Fri',
18
- 'Sat'
19
- ], aMonths = [
20
- 'Jan',
21
- 'Feb',
22
- 'Mar',
23
- 'Apr',
24
- 'May',
25
- 'Jun',
26
- 'Jul',
27
- 'Aug',
28
- 'Sep',
29
- 'Oct',
30
- 'Nov',
31
- 'Dec'
32
- ], mWeekdayToDay = {
33
- Sun: 0,
34
- Mon: 1,
35
- Tue: 2,
36
- Wed: 3,
37
- Thu: 4,
38
- Fri: 5,
39
- Sat: 6
40
- };
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
+ */
41
34
  function addLeadingZeros(iValue, iLength) {
42
- return (iValue < 0 ? '-' : '') + Math.abs(iValue).toString().padStart(iLength, '0');
35
+ return (iValue < 0 ? "-" : "") + Math.abs(iValue).toString().padStart(iLength, "0");
43
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
+ */
44
69
  function UI5Date(vDateParts, sTimezoneID) {
45
- var oDateInstance = UI5Date._createDateInstance(vDateParts);
46
- Object.defineProperties(this, {
47
- sTimezoneID: { value: sTimezoneID },
48
- oDate: {
49
- value: oDateInstance,
50
- writable: true
51
- },
52
- oDateParts: {
53
- value: undefined,
54
- writable: true
55
- }
56
- });
57
- if (isNaN(oDateInstance)) {
58
- return;
59
- }
60
- if (vDateParts.length > 1 || vDateParts.length === 1 && typeof vDateParts[0] === 'string' && !rIsUTCString.test(vDateParts[0])) {
61
- this._setParts(aAllParts, [
62
- oDateInstance.getFullYear(),
63
- oDateInstance.getMonth(),
64
- oDateInstance.getDate(),
65
- oDateInstance.getHours(),
66
- oDateInstance.getMinutes(),
67
- oDateInstance.getSeconds(),
68
- oDateInstance.getMilliseconds()
69
- ]);
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
70
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
+ }
71
93
  }
72
- UI5Date.prototype = Object.create(Date.prototype, { constructor: { value: Date } });
73
- UI5Date.prototype[Symbol.toStringTag] = 'Date';
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
+ */
74
112
  UI5Date.prototype._getPart = function (sPart) {
75
- var iResult;
76
- if (isNaN(this.oDate)) {
77
- return NaN;
78
- }
79
- this.oDateParts = this.oDateParts || TimezoneUtil._getParts(this.oDate, this.sTimezoneID);
80
- if (sPart === 'weekday') {
81
- return mWeekdayToDay[this.oDateParts.weekday];
82
- }
83
- iResult = parseInt(this.oDateParts[sPart]);
84
- if (sPart === 'month') {
85
- iResult -= 1;
86
- } else if (sPart === 'year') {
87
- if (this.oDateParts.era === 'B') {
88
- iResult = 1 - iResult;
89
- }
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;
90
127
  }
91
- return iResult;
128
+ }
129
+ return iResult;
92
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
+ */
93
146
  UI5Date.prototype._setParts = function (aParts, aValues) {
94
- var i, oCurrentDateParts, oNewDateAsUTCTimestamp, iNewTimestamp, sPart, vValue, oDateParts = {}, iMaxLength = Math.min(aParts.length, aValues.length);
95
- if (iMaxLength === 0) {
96
- return this.setTime(NaN);
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);
97
165
  }
98
- for (i = 0; i < iMaxLength; i += 1) {
99
- vValue = parseInt(+aValues[i]);
100
- sPart = aParts[i];
101
- if (isNaN(vValue)) {
102
- return this.setTime(NaN);
103
- }
104
- if (sPart === 'month') {
105
- vValue += 1;
106
- } else if (sPart === 'year') {
107
- if (vValue <= 0) {
108
- vValue = 1 - vValue;
109
- oDateParts.era = 'B';
110
- } else {
111
- oDateParts.era = 'A';
112
- }
113
- }
114
- oDateParts[sPart] = vValue.toString();
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
+ }
115
175
  }
116
- if (this.oDateParts) {
117
- oCurrentDateParts = this.oDateParts;
118
- } else if (isNaN(this.oDate)) {
119
- oCurrentDateParts = {
120
- day: '1',
121
- fractionalSecond: '0',
122
- hour: '0',
123
- minute: '0',
124
- month: '1',
125
- second: '0'
126
- };
127
- } else {
128
- oCurrentDateParts = TimezoneUtil._getParts(this.oDate, this.sTimezoneID);
129
- }
130
- oDateParts = Object.assign({}, oCurrentDateParts, oDateParts);
131
- oNewDateAsUTCTimestamp = TimezoneUtil._getDateFromParts(oDateParts);
132
- if (isNaN(oNewDateAsUTCTimestamp)) {
133
- return this.setTime(NaN);
134
- }
135
- iNewTimestamp = oNewDateAsUTCTimestamp.getTime() + TimezoneUtil.calculateOffset(oNewDateAsUTCTimestamp, this.sTimezoneID) * 1000;
136
- return this.setTime(iNewTimestamp);
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);
137
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
+ */
138
211
  UI5Date.prototype.clone = function () {
139
- return UI5Date.getInstance(this);
212
+ return UI5Date.getInstance(this);
140
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
+ */
141
225
  UI5Date.prototype.getDate = function () {
142
- return this._getPart('day');
226
+ return this._getPart("day");
143
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
+ */
144
239
  UI5Date.prototype.getDay = function () {
145
- return this._getPart('weekday');
240
+ return this._getPart("weekday");
146
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
+ */
147
251
  UI5Date.prototype.getFullYear = function () {
148
- return this._getPart('year');
252
+ return this._getPart("year");
149
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
+ */
150
265
  UI5Date.prototype.getHours = function () {
151
- return this._getPart('hour');
266
+ return this._getPart("hour");
152
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
+ */
153
279
  UI5Date.prototype.getMilliseconds = function () {
154
- return this._getPart('fractionalSecond');
280
+ return this._getPart("fractionalSecond");
155
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
+ */
156
293
  UI5Date.prototype.getMinutes = function () {
157
- return this._getPart('minute');
294
+ return this._getPart("minute");
158
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
+ */
159
307
  UI5Date.prototype.getMonth = function () {
160
- return this._getPart('month');
308
+ return this._getPart("month");
161
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
+ */
162
321
  UI5Date.prototype.getSeconds = function () {
163
- return this._getPart('second');
322
+ return this._getPart("second");
164
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
+ */
165
334
  UI5Date.prototype.getTimezoneOffset = function () {
166
- return TimezoneUtil.calculateOffset(this.oDate, this.sTimezoneID) / 60;
335
+ return TimezoneUtil.calculateOffset(this.oDate, this.sTimezoneID) / 60;
167
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
+ */
168
349
  UI5Date.prototype.getYear = function () {
169
- return this._getPart('year') - 1900;
350
+ return this._getPart("year") - 1900;
170
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
+ */
171
365
  UI5Date.prototype.setDate = function (iDay) {
172
- return this._setParts(['day'], arguments);
366
+ return this._setParts(["day"], arguments);
173
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
+ */
174
382
  UI5Date.prototype.setFullYear = function (iYear, iMonth, iDay) {
175
- return this._setParts([
176
- 'year',
177
- 'month',
178
- 'day'
179
- ], arguments);
383
+ return this._setParts(["year", "month", "day"], arguments);
180
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
+ */
181
400
  UI5Date.prototype.setHours = function (iHours, iMinutes, iSeconds, iMilliseconds) {
182
- return this._setParts([
183
- 'hour',
184
- 'minute',
185
- 'second',
186
- 'fractionalSecond'
187
- ], arguments);
401
+ return this._setParts(["hour", "minute", "second", "fractionalSecond"], arguments);
188
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
+ */
189
415
  UI5Date.prototype.setMilliseconds = function (iMilliseconds) {
190
- return this._setParts(['fractionalSecond'], arguments);
416
+ return this._setParts(["fractionalSecond"], arguments);
191
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
+ */
192
432
  UI5Date.prototype.setMinutes = function (iMinutes, iSeconds, iMilliseconds) {
193
- return this._setParts([
194
- 'minute',
195
- 'second',
196
- 'fractionalSecond'
197
- ], arguments);
433
+ return this._setParts(["minute", "second", "fractionalSecond"], arguments);
198
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
+ */
199
448
  UI5Date.prototype.setMonth = function (iMonth, iDay) {
200
- return this._setParts([
201
- 'month',
202
- 'day'
203
- ], arguments);
449
+ return this._setParts(["month", "day"], arguments);
204
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
+ */
205
464
  UI5Date.prototype.setSeconds = function (iSeconds, iMilliseconds) {
206
- return this._setParts([
207
- 'second',
208
- 'fractionalSecond'
209
- ], arguments);
465
+ return this._setParts(["second", "fractionalSecond"], arguments);
210
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
+ */
211
480
  UI5Date.prototype.setTime = function (iTime) {
212
- this.oDateParts = undefined;
213
- return this.oDate.setTime(iTime);
481
+ this.oDateParts = undefined;
482
+ return this.oDate.setTime(iTime);
214
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
+ */
215
500
  UI5Date.prototype.setYear = function (iYear) {
216
- return this._setParts(['year'], [parseInt(iYear) + 1900]);
501
+ var iValue = parseInt(iYear);
502
+ iValue = iValue < 0 || iValue > 99 ? iValue : iValue + 1900;
503
+ return this._setParts(["year"], [iValue]);
217
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
+ */
218
772
  UI5Date.prototype.toDateString = function () {
219
- if (isNaN(this.oDate)) {
220
- return this.oDate.toDateString();
221
- }
222
- return aWeekday[this.getDay()] + ' ' + aMonths[this.getMonth()] + ' ' + addLeadingZeros(this.getDate(), 2) + ' ' + addLeadingZeros(this.getFullYear(), 4);
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);
223
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
+ */
224
846
  UI5Date.prototype.toString = function () {
225
- if (isNaN(this.oDate)) {
226
- return this.oDate.toString();
227
- }
228
- return this.toDateString() + ' ' + this.toTimeString();
847
+ if (isNaN(this.oDate)) {
848
+ return this.oDate.toString();
849
+ }
850
+ return this.toDateString() + " " + this.toTimeString();
229
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
+ */
230
861
  UI5Date.prototype.toTimeString = function () {
231
- var iHours, iMinutes, sSign, iTimeZoneOffset;
232
- if (isNaN(this.oDate)) {
233
- return this.oDate.toTimeString();
234
- }
235
- iTimeZoneOffset = this.getTimezoneOffset();
236
- sSign = iTimeZoneOffset > 0 ? '-' : '+';
237
- iHours = Math.floor(Math.abs(iTimeZoneOffset) / 60);
238
- iMinutes = Math.abs(iTimeZoneOffset) % 60;
239
- return addLeadingZeros(this.getHours(), 2) + ':' + addLeadingZeros(this.getMinutes(), 2) + ':' + addLeadingZeros(this.getSeconds(), 2) + ' GMT' + sSign + addLeadingZeros(iHours, 2) + addLeadingZeros(iMinutes, 2);
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);
240
873
  };
241
- [
242
- 'getTime',
243
- 'getUTCDate',
244
- 'getUTCDay',
245
- 'getUTCFullYear',
246
- 'getUTCHours',
247
- 'getUTCMilliseconds',
248
- 'getUTCMinutes',
249
- 'getUTCMonth',
250
- 'getUTCSeconds',
251
- 'toGMTString',
252
- 'toISOString',
253
- 'toJSON',
254
- 'toUTCString',
255
- 'valueOf'
256
- ].forEach(function (sMethod) {
257
- UI5Date.prototype[sMethod] = function () {
258
- return this.oDate[sMethod].apply(this.oDate, arguments);
259
- };
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
+ };
260
902
  });
261
- [
262
- 'toLocaleDateString',
263
- 'toLocaleString',
264
- 'toLocaleTimeString'
265
- ].forEach(function (sMethod) {
266
- UI5Date.prototype[sMethod] = function (sLocale, oOptions) {
267
- return this.oDate[sMethod](sLocale || Configuration.getLanguageTag(), Object.assign({ timeZone: this.sTimezoneID }, oOptions));
268
- };
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
+ };
269
909
  });
270
- [
271
- 'setUTCDate',
272
- 'setUTCFullYear',
273
- 'setUTCHours',
274
- 'setUTCMilliseconds',
275
- 'setUTCMinutes',
276
- 'setUTCMonth',
277
- 'setUTCSeconds'
278
- ].forEach(function (sMethod) {
279
- UI5Date.prototype[sMethod] = function () {
280
- this.oDateParts = undefined;
281
- return this.oDate[sMethod].apply(this.oDate, arguments);
282
- };
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
+ };
283
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
+ */
284
930
  UI5Date._createDateInstance = function (vParts) {
285
- if (vParts[0] instanceof Date) {
286
- vParts[0] = vParts[0].valueOf();
287
- }
288
- return new (Function.prototype.bind.apply(Date, [].concat.apply([null], 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)))();
289
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
+ */
290
963
  UI5Date.getInstance = function () {
291
- var sTimezone = Configuration.getTimezone();
292
- if (sTimezone !== TimezoneUtil.getLocalTimezone()) {
293
- return new UI5Date(arguments, sTimezone);
294
- }
295
- return UI5Date._createDateInstance(arguments);
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);
296
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
+ */
297
983
  UI5Date.checkDate = function (oDate) {
298
- if (isNaN(oDate.getTime())) {
299
- throw new Error('The given Date is not valid');
300
- }
301
- if (!(oDate instanceof UI5Date) && Configuration.getTimezone() !== TimezoneUtil.getLocalTimezone()) {
302
- throw new Error('Configured time zone requires the parameter \'oDate\' to be an instance of' + ' sap.ui.core.date.UI5Date');
303
- }
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
+ }
304
990
  };
305
991
  export default UI5Date;