@ui5/webcomponents-localization 1.22.0-rc.1 → 1.22.0-rc.2
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.
- package/CHANGELOG.md +8 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/generated/assets/cldr/ar.json +102 -62
- package/dist/generated/assets/cldr/ar_EG.json +102 -62
- package/dist/generated/assets/cldr/ar_SA.json +102 -62
- package/dist/generated/assets/cldr/bg.json +364 -325
- package/dist/generated/assets/cldr/ca.json +491 -453
- package/dist/generated/assets/cldr/cs.json +431 -324
- package/dist/generated/assets/cldr/cy.json +608 -340
- package/dist/generated/assets/cldr/da.json +290 -227
- package/dist/generated/assets/cldr/de.json +348 -241
- package/dist/generated/assets/cldr/de_AT.json +348 -241
- package/dist/generated/assets/cldr/de_CH.json +347 -240
- package/dist/generated/assets/cldr/el.json +128 -100
- package/dist/generated/assets/cldr/el_CY.json +128 -100
- package/dist/generated/assets/cldr/en.json +538 -512
- package/dist/generated/assets/cldr/en_AU.json +583 -520
- package/dist/generated/assets/cldr/en_GB.json +485 -441
- package/dist/generated/assets/cldr/en_HK.json +519 -474
- package/dist/generated/assets/cldr/en_IE.json +485 -440
- package/dist/generated/assets/cldr/en_IN.json +465 -420
- package/dist/generated/assets/cldr/en_NZ.json +505 -460
- package/dist/generated/assets/cldr/en_PG.json +505 -460
- package/dist/generated/assets/cldr/en_SG.json +505 -460
- package/dist/generated/assets/cldr/en_ZA.json +485 -440
- package/dist/generated/assets/cldr/es.json +709 -456
- package/dist/generated/assets/cldr/es_AR.json +687 -434
- package/dist/generated/assets/cldr/es_BO.json +721 -468
- package/dist/generated/assets/cldr/es_CL.json +567 -422
- package/dist/generated/assets/cldr/es_CO.json +485 -339
- package/dist/generated/assets/cldr/es_MX.json +734 -481
- package/dist/generated/assets/cldr/es_PE.json +409 -372
- package/dist/generated/assets/cldr/es_UY.json +433 -396
- package/dist/generated/assets/cldr/es_VE.json +453 -416
- package/dist/generated/assets/cldr/et.json +340 -307
- package/dist/generated/assets/cldr/fa.json +96 -34
- package/dist/generated/assets/cldr/fi.json +359 -308
- package/dist/generated/assets/cldr/fr.json +347 -321
- package/dist/generated/assets/cldr/fr_BE.json +347 -321
- package/dist/generated/assets/cldr/fr_CA.json +458 -432
- package/dist/generated/assets/cldr/fr_CH.json +290 -264
- package/dist/generated/assets/cldr/fr_LU.json +347 -321
- package/dist/generated/assets/cldr/he.json +241 -130
- package/dist/generated/assets/cldr/hi.json +103 -53
- package/dist/generated/assets/cldr/hr.json +467 -410
- package/dist/generated/assets/cldr/hu.json +246 -195
- package/dist/generated/assets/cldr/id.json +478 -406
- package/dist/generated/assets/cldr/it.json +418 -362
- package/dist/generated/assets/cldr/it_CH.json +418 -362
- package/dist/generated/assets/cldr/ja.json +58 -18
- package/dist/generated/assets/cldr/kk.json +562 -398
- package/dist/generated/assets/cldr/ko.json +36 -15
- package/dist/generated/assets/cldr/lt.json +320 -231
- package/dist/generated/assets/cldr/lv.json +184 -120
- package/dist/generated/assets/cldr/ms.json +460 -388
- package/dist/generated/assets/cldr/nb.json +160 -92
- package/dist/generated/assets/cldr/nl.json +621 -373
- package/dist/generated/assets/cldr/nl_BE.json +621 -373
- package/dist/generated/assets/cldr/pl.json +590 -279
- package/dist/generated/assets/cldr/pt.json +696 -334
- package/dist/generated/assets/cldr/pt_PT.json +730 -454
- package/dist/generated/assets/cldr/ro.json +409 -339
- package/dist/generated/assets/cldr/ru.json +317 -279
- package/dist/generated/assets/cldr/ru_UA.json +312 -274
- package/dist/generated/assets/cldr/sk.json +454 -413
- package/dist/generated/assets/cldr/sl.json +118 -80
- package/dist/generated/assets/cldr/sr.json +294 -142
- package/dist/generated/assets/cldr/sr_Latn.json +972 -824
- package/dist/generated/assets/cldr/sv.json +382 -338
- package/dist/generated/assets/cldr/th.json +56 -36
- package/dist/generated/assets/cldr/tr.json +371 -320
- package/dist/generated/assets/cldr/uk.json +340 -290
- package/dist/generated/assets/cldr/vi.json +352 -328
- package/dist/generated/assets/cldr/zh_CN.json +34 -10
- package/dist/generated/assets/cldr/zh_HK.json +33 -9
- package/dist/generated/assets/cldr/zh_SG.json +33 -9
- package/dist/generated/assets/cldr/zh_TW.json +32 -8
- package/dist/sap/base/Event.js +59 -0
- package/dist/sap/base/Eventing.js +146 -0
- package/dist/sap/base/Log.js +2 -239
- package/dist/sap/base/assert.js +28 -1
- package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
- package/dist/sap/base/config.js +17 -0
- package/dist/sap/base/i18n/Formatting.js +1130 -0
- package/dist/sap/base/i18n/LanguageTag.js +168 -30
- package/dist/sap/base/i18n/date/CalendarType.js +36 -1
- package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +76 -1
- package/dist/sap/base/i18n/date/TimezoneUtils.js +242 -12
- package/dist/sap/base/strings/camelize.js +30 -0
- package/dist/sap/base/strings/formatMessage.js +88 -15
- package/dist/sap/base/util/ObjectPath.js +95 -3
- package/dist/sap/base/util/Version.js +157 -0
- package/dist/sap/base/util/_merge.js +83 -26
- package/dist/sap/base/util/array/uniqueSort.js +37 -15
- package/dist/sap/base/util/deepClone.js +102 -0
- package/dist/sap/base/util/deepEqual.js +75 -51
- package/dist/sap/base/util/extend.js +58 -7
- package/dist/sap/base/util/isEmptyObject.js +34 -0
- package/dist/sap/base/util/isPlainObject.js +35 -1
- package/dist/sap/base/util/now.js +24 -3
- package/dist/sap/base/util/resolveReference.js +157 -0
- package/dist/sap/base/util/uid.js +27 -0
- package/dist/sap/ui/base/DataType.js +657 -0
- package/dist/sap/ui/base/Interface.js +47 -1
- package/dist/sap/ui/base/Metadata.js +433 -180
- package/dist/sap/ui/base/Object.js +284 -48
- package/dist/sap/ui/core/CalendarType.js +23 -1
- package/dist/sap/ui/core/Locale.js +189 -57
- package/dist/sap/ui/core/LocaleData.js +2670 -1380
- package/dist/sap/ui/core/Supportability.js +5 -0
- package/dist/sap/ui/core/Theming.js +539 -0
- package/dist/sap/ui/core/date/Buddhist.js +162 -87
- package/dist/sap/ui/core/date/CalendarUtils.js +61 -21
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +29 -1
- package/dist/sap/ui/core/date/Gregorian.js +25 -10
- package/dist/sap/ui/core/date/Islamic.js +298 -185
- package/dist/sap/ui/core/date/Japanese.js +210 -115
- package/dist/sap/ui/core/date/Persian.js +324 -195
- package/dist/sap/ui/core/date/UI5Date.js +923 -237
- package/dist/sap/ui/core/date/UniversalDate.js +1238 -245
- package/dist/sap/ui/core/date/_Calendars.js +10 -1
- package/dist/sap/ui/core/format/DateFormat.js +3163 -2145
- package/dist/sap/ui/core/format/TimezoneUtil.js +23 -1
- package/package-scripts.cjs +4 -10
- package/package.json +9 -5
- package/used-modules.txt +20 -1
- package/dist/sap/ui/Device.js +0 -5
@@ -1,331 +1,1324 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
import
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
import Core from "../Core.js"; /*!
|
2
|
+
* OpenUI5
|
3
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
4
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
5
|
+
*/
|
6
|
+
// Provides class sap.ui.core.date.UniversalDate
|
7
|
+
import BaseObject from "../../base/Object.js";
|
8
|
+
import Configuration from "../Configuration.js";
|
9
|
+
import LocaleData from "../LocaleData.js";
|
10
|
+
import _Calendars from "./_Calendars.js";
|
11
|
+
import CalendarUtils from "./CalendarUtils.js";
|
12
|
+
import CalendarWeekNumbering from "./CalendarWeekNumbering.js";
|
13
|
+
import UI5Date from "./UI5Date.js";
|
14
|
+
/**
|
15
|
+
* Constructor for UniversalDate.
|
16
|
+
*
|
17
|
+
* @class
|
18
|
+
* The UniversalDate is the base class of calendar date instances. It contains the static methods to create calendar
|
19
|
+
* specific instances.
|
20
|
+
*
|
21
|
+
* The member variable <code>this.oDate</code> contains a date instance
|
22
|
+
* (either JavaScript Date or <code>module:sap/ui/core/date/UI5Date</code>) which considers the
|
23
|
+
* configured time zone wherever JavaScript Date uses the local browser time zone; see
|
24
|
+
* {@link module:sap/ui/core/date/UI5Date#getInstance}. This is the source value of the date
|
25
|
+
* information. The prototype contains getters and setters of the Date and is delegating them
|
26
|
+
* to the internal date object. Implementations for specific calendars may override methods
|
27
|
+
* needed for their specific calendar (e.g. getYear and getEra for Japanese emperor calendar).
|
28
|
+
*
|
29
|
+
* @private
|
30
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
31
|
+
* @alias sap.ui.core.date.UniversalDate
|
32
|
+
*/
|
33
|
+
var UniversalDate = BaseObject.extend("sap.ui.core.date.UniversalDate", /** @lends sap.ui.core.date.UniversalDate.prototype */{
|
34
|
+
constructor: function () {
|
35
|
+
var clDate = UniversalDate.getClass();
|
36
|
+
return this.createDate(clDate, arguments);
|
37
|
+
}
|
13
38
|
});
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Delegates this method to the calender specific implementation.
|
42
|
+
*
|
43
|
+
* @returns {int}
|
44
|
+
* The number of milliseconds since January 1, 1970, 00:00:00 UTC based on the Gregorian
|
45
|
+
* calendar, for the given calendar specific arguments
|
46
|
+
*
|
47
|
+
* @private
|
48
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
49
|
+
*/
|
14
50
|
UniversalDate.UTC = function () {
|
15
|
-
|
16
|
-
|
51
|
+
var clDate = UniversalDate.getClass();
|
52
|
+
return clDate.UTC.apply(clDate, arguments);
|
17
53
|
};
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Returns a number representing the millisecond since January 1, 1970, 00:00:00 to the current date,
|
57
|
+
* see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now Date.now}.
|
58
|
+
*
|
59
|
+
* @returns {int} A number representing the millisecond since January 1, 1970, 00:00:00 to the current date
|
60
|
+
*
|
61
|
+
* @private
|
62
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
63
|
+
*/
|
18
64
|
UniversalDate.now = function () {
|
19
|
-
|
65
|
+
return Date.now();
|
20
66
|
};
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Creates an object of the provided date class and with the given arguments.
|
70
|
+
*
|
71
|
+
* @param {function} clDate
|
72
|
+
* The constructor function for either <code>Date</code> or an implementation of
|
73
|
+
* <code>sap.ui.core.date.UniversalDate</code>
|
74
|
+
* @param {object} aArgs
|
75
|
+
* The <code>arguments</code> object which is given to the constructor of the given date class
|
76
|
+
* to create the date object
|
77
|
+
* @returns {sap.ui.core.date.UniversalDate|module:sap/ui/core/date/UI5Date}
|
78
|
+
* The created date, either an UI5Date or UniversalDate instance
|
79
|
+
*
|
80
|
+
* @private
|
81
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
82
|
+
*/
|
21
83
|
UniversalDate.prototype.createDate = function (clDate, aArgs) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
84
|
+
if (clDate === Date) {
|
85
|
+
return UI5Date.getInstance.apply(null, aArgs);
|
86
|
+
}
|
87
|
+
switch (aArgs.length) {
|
26
88
|
case 0:
|
27
|
-
|
89
|
+
return new clDate();
|
90
|
+
// new Date(new Date()) is officially not supported
|
91
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
|
28
92
|
case 1:
|
29
|
-
|
93
|
+
return new clDate(aArgs[0] instanceof Date ? aArgs[0].getTime() : aArgs[0]);
|
30
94
|
case 2:
|
31
|
-
|
95
|
+
return new clDate(aArgs[0], aArgs[1]);
|
32
96
|
case 3:
|
33
|
-
|
97
|
+
return new clDate(aArgs[0], aArgs[1], aArgs[2]);
|
34
98
|
case 4:
|
35
|
-
|
99
|
+
return new clDate(aArgs[0], aArgs[1], aArgs[2], aArgs[3]);
|
36
100
|
case 5:
|
37
|
-
|
101
|
+
return new clDate(aArgs[0], aArgs[1], aArgs[2], aArgs[3], aArgs[4]);
|
38
102
|
case 6:
|
39
|
-
|
103
|
+
return new clDate(aArgs[0], aArgs[1], aArgs[2], aArgs[3], aArgs[4], aArgs[5]);
|
40
104
|
case 7:
|
41
|
-
|
42
|
-
|
105
|
+
return new clDate(aArgs[0], aArgs[1], aArgs[2], aArgs[3], aArgs[4], aArgs[5], aArgs[6]);
|
106
|
+
}
|
43
107
|
};
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Returns an instance of UniversalDate, based on the calendar type from the configuration, or as explicitly
|
111
|
+
* defined by parameter. The object contains getters and setters of the JavaScript Date and is delegating them
|
112
|
+
* to an internal date object.
|
113
|
+
*
|
114
|
+
* Note: Prefer this method over calling <code>new UniversalDate</code> with an instance of <code>Date</code>.
|
115
|
+
*
|
116
|
+
* @param {Date|module:sap/ui/core/date/UI5Date|sap.ui.core.date.UniversalDate} [oDate]
|
117
|
+
* The date object, defaults to <code>UI5Date.getInstance()</code>
|
118
|
+
* @param {sap.ui.core.CalendarType} [sCalendarType]
|
119
|
+
* The calendar type, defaults to <code>Core.getConfiguration().getCalendarType()</code>
|
120
|
+
* @returns {sap.ui.core.date.UniversalDate}
|
121
|
+
* An instance of <code>UniversalDate</code>
|
122
|
+
*
|
123
|
+
* @private
|
124
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
125
|
+
*/
|
44
126
|
UniversalDate.getInstance = function (oDate, sCalendarType) {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
127
|
+
var clDate, oInstance;
|
128
|
+
if (oDate instanceof UniversalDate) {
|
129
|
+
oDate = oDate.getJSDate();
|
130
|
+
}
|
131
|
+
if (oDate && isNaN(oDate.getTime())) {
|
132
|
+
throw new Error("The given date object is invalid");
|
133
|
+
}
|
134
|
+
if (!sCalendarType) {
|
135
|
+
sCalendarType = Configuration.getCalendarType();
|
136
|
+
}
|
137
|
+
clDate = UniversalDate.getClass(sCalendarType);
|
138
|
+
oInstance = Object.create(clDate.prototype);
|
139
|
+
oInstance.oDate = oDate ? UI5Date.getInstance(oDate) : UI5Date.getInstance();
|
140
|
+
oInstance.sCalendarType = sCalendarType;
|
141
|
+
return oInstance;
|
60
142
|
};
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Returns the constructor function of a subclass of <code>UniversalDate</code> for the given calendar type.
|
146
|
+
* If no calendar type is given the globally configured calendar type is used.
|
147
|
+
*
|
148
|
+
* @param {sap.ui.core.CalendarType} sCalendarType the type of the used calendar
|
149
|
+
*
|
150
|
+
* @returns {function}
|
151
|
+
* The class of the given <code>sCalenderType</code>. If <code>sCalenderType</code> is not
|
152
|
+
* provided, the class of the configured calendar type is returned.
|
153
|
+
*
|
154
|
+
* @private
|
155
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
156
|
+
*/
|
61
157
|
UniversalDate.getClass = function (sCalendarType) {
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
158
|
+
if (!sCalendarType) {
|
159
|
+
sCalendarType = Configuration.getCalendarType();
|
160
|
+
}
|
161
|
+
return _Calendars.get(sCalendarType);
|
66
162
|
};
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Returns the day of the month of the embedded date instance according to the configured time
|
166
|
+
* zone and selected calender.
|
167
|
+
*
|
168
|
+
* @returns {int}
|
169
|
+
* A number representing the day of the month of the embedded date instance according
|
170
|
+
* to the configured time zone and selected calender
|
171
|
+
*
|
172
|
+
* @function
|
173
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getDate
|
174
|
+
* @private
|
175
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
176
|
+
*/
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Returns the day of the week of the embedded date instance according to the configured time zone and
|
180
|
+
* selected calender.
|
181
|
+
*
|
182
|
+
* @returns {int}
|
183
|
+
* A number representing the day of the week of the embedded date instance according to the configured
|
184
|
+
* time zone and selected calender
|
185
|
+
*
|
186
|
+
* @function
|
187
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getDay
|
188
|
+
* @private
|
189
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
190
|
+
*/
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Returns the year of the embedded date instance according to the configured time zone and selected calender.
|
194
|
+
*
|
195
|
+
* @returns {int}
|
196
|
+
* The year of the embedded date instance according to the configured time zone and selected calender
|
197
|
+
*
|
198
|
+
* @function
|
199
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getFullYear
|
200
|
+
* @private
|
201
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
202
|
+
*/
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Returns the hours of the embedded date instance according to the configured time zone and selected
|
206
|
+
* calender.
|
207
|
+
*
|
208
|
+
* @returns {int}
|
209
|
+
* A number representing the hours of the embedded date instance according to the configured time zone
|
210
|
+
* and selected calender
|
211
|
+
*
|
212
|
+
* @function
|
213
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getHours
|
214
|
+
* @private
|
215
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
216
|
+
*/
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Returns the milliseconds of the embedded date instance according to the configured time zone
|
220
|
+
* and selected calender.
|
221
|
+
*
|
222
|
+
* @returns {int}
|
223
|
+
* A number between 0 and 999 representing the milliseconds of the embedded date instance according to
|
224
|
+
* the configured time zone and selected calender
|
225
|
+
*
|
226
|
+
* @function
|
227
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getMilliseconds
|
228
|
+
* @private
|
229
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
230
|
+
*/
|
231
|
+
|
232
|
+
/**
|
233
|
+
* Returns the minutes of the embedded date instance according to the configured time zone and selected calender.
|
234
|
+
*
|
235
|
+
* @returns {int}
|
236
|
+
* A number between 0 and 59 representing the minutes of the embedded date instance according to the
|
237
|
+
* configured time zone and selected calender
|
238
|
+
*
|
239
|
+
* @function
|
240
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getMinutes
|
241
|
+
* @private
|
242
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
243
|
+
*/
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Returns the month index of the embedded date instance according to the configured time zone
|
247
|
+
* and selected calender.
|
248
|
+
*
|
249
|
+
* @returns {int}
|
250
|
+
* The month index of the embedded date instance according to the configured time zone and selected calender
|
251
|
+
*
|
252
|
+
* @function
|
253
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getMonth
|
254
|
+
* @private
|
255
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
256
|
+
*/
|
257
|
+
|
258
|
+
/**
|
259
|
+
* Returns the seconds of the embedded date instance according to the configured time zone and selected calender.
|
260
|
+
*
|
261
|
+
* @returns {int}
|
262
|
+
* A number between 0 and 59 representing the seconds of the embedded date instance according to the
|
263
|
+
* configured time zone and selected calender
|
264
|
+
*
|
265
|
+
* @function
|
266
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getSeconds
|
267
|
+
* @private
|
268
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
269
|
+
*/
|
270
|
+
|
271
|
+
/**
|
272
|
+
* Returns the difference in minutes between the UTC and the configured time zone for the embedded date.
|
273
|
+
*
|
274
|
+
* @returns {int}
|
275
|
+
* The difference in minutes between the UTC and the configured time zone for the embedded date
|
276
|
+
*
|
277
|
+
* @function
|
278
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getTimezoneOffset
|
279
|
+
* @private
|
280
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
281
|
+
*/
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Returns the year of the embedded date instance minus 1900 according to the configured time zone and
|
285
|
+
* selected calender. In case of the Gregorian calendar the 1900 is subtracted from the year value.
|
286
|
+
*
|
287
|
+
* @returns {int}
|
288
|
+
* The year of the embedded date instance (minus 1900 if the Gregorian calendar is selected)
|
289
|
+
* according to the configured time zone and selected calender
|
290
|
+
*
|
291
|
+
* @deprecated for the Gregorian calendar since version 1.111.0 as it is deprecated in
|
292
|
+
* JavaScript Date, it can be used with other calendars. It still is recommended to use
|
293
|
+
* {@link #getFullYear} instead, independent on the selected calender
|
294
|
+
*
|
295
|
+
* @function
|
296
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getYear
|
297
|
+
* @private
|
298
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
299
|
+
*/
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Returns the timestamp in milliseconds of the embedded date based on the UNIX epoch.
|
303
|
+
*
|
304
|
+
* @returns {int}
|
305
|
+
* The timestamp in milliseconds of the embedded date based on the UNIX epoch, or <code>NaN</code> if
|
306
|
+
* the embedded date is an invalid date
|
307
|
+
*
|
308
|
+
* @function
|
309
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getTime
|
310
|
+
* @private
|
311
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
312
|
+
*/
|
313
|
+
|
314
|
+
/**
|
315
|
+
* Returns the day of the month of the embedded date instance according to universal time and
|
316
|
+
* selected calender.
|
317
|
+
*
|
318
|
+
* @returns {int}
|
319
|
+
* A number representing the day of the month of the embedded date instance according
|
320
|
+
* to universal time and selected calender
|
321
|
+
*
|
322
|
+
* @function
|
323
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getUTCDate
|
324
|
+
* @private
|
325
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
326
|
+
*/
|
327
|
+
|
328
|
+
/**
|
329
|
+
*
|
330
|
+
* Returns the day of the week of the embedded date instance according to universal time and
|
331
|
+
* selected calender.
|
332
|
+
*
|
333
|
+
* @returns {int}
|
334
|
+
* A number representing the day of the week of the embedded date instance according to universal
|
335
|
+
* time and selected calender
|
336
|
+
*
|
337
|
+
* @function
|
338
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getUTCDay
|
339
|
+
* @private
|
340
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
341
|
+
*/
|
342
|
+
|
343
|
+
/**
|
344
|
+
* Returns the year of the embedded date instance according to universal time and selected calender.
|
345
|
+
*
|
346
|
+
* @returns {int}
|
347
|
+
* The year of the embedded date instance according to universal time and selected calender
|
348
|
+
*
|
349
|
+
* @function
|
350
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getUTCFullYear
|
351
|
+
* @private
|
352
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
353
|
+
*/
|
354
|
+
|
355
|
+
/**
|
356
|
+
* Returns the hours of the embedded date instance according to universal time.
|
357
|
+
*
|
358
|
+
* @returns {int}
|
359
|
+
* A number representing the hours of the embedded date instance according to universal time
|
360
|
+
*
|
361
|
+
* @function
|
362
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getUTCHours
|
363
|
+
* @private
|
364
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
365
|
+
*/
|
366
|
+
|
367
|
+
/**
|
368
|
+
* Returns the milliseconds of the embedded date instance according to universal time.
|
369
|
+
*
|
370
|
+
* @returns {int}
|
371
|
+
* A number between 0 and 999 representing the milliseconds of the embedded date instance
|
372
|
+
* according to universal time
|
373
|
+
*
|
374
|
+
* @function
|
375
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getUTCMilliseconds
|
376
|
+
* @private
|
377
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
378
|
+
*/
|
379
|
+
|
380
|
+
/**
|
381
|
+
* Returns the minutes of the embedded date instance according to universal time.
|
382
|
+
*
|
383
|
+
* @returns {int}
|
384
|
+
* A number between 0 and 59 representing the minutes of the embedded date instance according
|
385
|
+
* to universal time
|
386
|
+
*
|
387
|
+
* @function
|
388
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getUTCMinutes
|
389
|
+
* @private
|
390
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
391
|
+
*/
|
392
|
+
|
393
|
+
/**
|
394
|
+
* Returns the month index of the embedded date instance according to universal time and
|
395
|
+
* selected calender.
|
396
|
+
*
|
397
|
+
* @returns {int}
|
398
|
+
* The month index of the embedded date instance according to universal time and selected
|
399
|
+
* calender
|
400
|
+
*
|
401
|
+
* @function
|
402
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getUTCMonth
|
403
|
+
* @private
|
404
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
405
|
+
*/
|
406
|
+
|
407
|
+
/**
|
408
|
+
* Returns the seconds of the embedded date instance according to universal time.
|
409
|
+
*
|
410
|
+
* @returns {int}
|
411
|
+
* A number between 0 and 59 representing the seconds of the embedded date instance according
|
412
|
+
* to universal time
|
413
|
+
*
|
414
|
+
* @function
|
415
|
+
* @name sap.ui.core.date.UniversalDate.prototype.getUTCSeconds
|
416
|
+
* @private
|
417
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
418
|
+
*/
|
419
|
+
|
420
|
+
/**
|
421
|
+
* Sets the day of the month for the embedded date instance considering the configured time zone
|
422
|
+
* and selected calender.
|
423
|
+
*
|
424
|
+
* @param {int} iDay
|
425
|
+
* An integer representing the new day 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. The new timestamp is a Gregorian timestamp.
|
429
|
+
*
|
430
|
+
* @function
|
431
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setDate
|
432
|
+
* @private
|
433
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
434
|
+
*/
|
435
|
+
|
436
|
+
/**
|
437
|
+
* Sets the year, month and day for the embedded date instance considering the configured time
|
438
|
+
* zone and selected calender.
|
439
|
+
*
|
440
|
+
* @param {int} yearValue An integer representing the new year value
|
441
|
+
* @param {int} [monthValue] An integer representing the new month index
|
442
|
+
* @param {int} [dateValue] An integer representing the new day value
|
443
|
+
* @returns {int}
|
444
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
445
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
446
|
+
*
|
447
|
+
* @function
|
448
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setFullYear
|
449
|
+
* @private
|
450
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
451
|
+
*/
|
452
|
+
|
453
|
+
/**
|
454
|
+
* Sets the hours, minutes, seconds and milliseconds for the embedded date instance considering
|
455
|
+
* the configured time zone.
|
456
|
+
*
|
457
|
+
* @param {int} hoursValue An integer representing the new hours value
|
458
|
+
* @param {int} [minutesValue] An integer representing the new minutes value
|
459
|
+
* @param {int} [secondsValue] An integer representing the new seconds value
|
460
|
+
* @param {int} [msValue] An integer representing the new milliseconds value
|
461
|
+
* @returns {int}
|
462
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
463
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
464
|
+
*
|
465
|
+
* @function
|
466
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setHours
|
467
|
+
* @private
|
468
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
469
|
+
*/
|
470
|
+
|
471
|
+
/**
|
472
|
+
* Sets the milliseconds for the embedded date instance considering the configured time zone.
|
473
|
+
*
|
474
|
+
* @param {int} millisecondsValue An integer representing the new milliseconds value
|
475
|
+
* @returns {int}
|
476
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
477
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
478
|
+
*
|
479
|
+
* @function
|
480
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setMilliseconds
|
481
|
+
* @private
|
482
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
483
|
+
*/
|
484
|
+
|
485
|
+
/**
|
486
|
+
* Sets the minutes, seconds and milliseconds for the embedded date instance considering the configured
|
487
|
+
* time zone.
|
488
|
+
*
|
489
|
+
* @param {int} minutesValue An integer representing the new minutes value
|
490
|
+
* @param {int} [secondsValue] An integer representing the new seconds value
|
491
|
+
* @param {int} [msValue] An integer representing the new milliseconds value
|
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. The new timestamp is a Gregorian timestamp.
|
495
|
+
*
|
496
|
+
* @function
|
497
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setMinutes
|
498
|
+
* @private
|
499
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
500
|
+
*/
|
501
|
+
|
502
|
+
/**
|
503
|
+
* Sets the month and day for the embedded date instance considering the configured time zone and
|
504
|
+
* selected calender.
|
505
|
+
*
|
506
|
+
* @param {int} monthValue An integer representing the new month index
|
507
|
+
* @param {int} [dayValue] An integer representing the new day value
|
508
|
+
* @returns {int}
|
509
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
510
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
511
|
+
*
|
512
|
+
* @function
|
513
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setMonth
|
514
|
+
* @private
|
515
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
516
|
+
*/
|
517
|
+
|
518
|
+
/**
|
519
|
+
* Sets the seconds and milliseconds for the embedded date instance considering the configured time zone.
|
520
|
+
*
|
521
|
+
* @param {int} secondsValue An integer representing the new seconds value
|
522
|
+
* @param {int} [msValue] An integer representing the new milliseconds value
|
523
|
+
* @returns {int}
|
524
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
525
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
526
|
+
*
|
527
|
+
* @function
|
528
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setSeconds
|
529
|
+
* @private
|
530
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
531
|
+
*/
|
532
|
+
|
533
|
+
/**
|
534
|
+
* Sets the day of the month for the embedded date instance according to universal time and
|
535
|
+
* selected calender.
|
536
|
+
*
|
537
|
+
* @param {int} dayValue
|
538
|
+
* An integer representing the new day value
|
539
|
+
* @returns {int}
|
540
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
541
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
542
|
+
*
|
543
|
+
* @function
|
544
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setUTCDate
|
545
|
+
* @private
|
546
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
547
|
+
*/
|
548
|
+
|
549
|
+
/**
|
550
|
+
* Sets the year, month and day for the embedded date instance according to universal time and
|
551
|
+
* selected calender.
|
552
|
+
*
|
553
|
+
* @param {int} yearValue An integer representing the new year value
|
554
|
+
* @param {int} [monthValue] An integer representing the new month index
|
555
|
+
* @param {int} [dateValue] An integer representing the new day value
|
556
|
+
* @returns {int}
|
557
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
558
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
559
|
+
*
|
560
|
+
* @function
|
561
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setUTCFullYear
|
562
|
+
* @private
|
563
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
564
|
+
*/
|
565
|
+
|
566
|
+
/**
|
567
|
+
* Sets the hours, minutes, seconds and milliseconds for the embedded date instance according to
|
568
|
+
* universal time.
|
569
|
+
*
|
570
|
+
* @param {int} hoursValue An integer representing the new hours value
|
571
|
+
* @param {int} [minutesValue] An integer representing the new minutes value
|
572
|
+
* @param {int} [secondsValue] An integer representing the new seconds value
|
573
|
+
* @param {int} [msValue] An integer representing the new milliseconds value
|
574
|
+
* @returns {int}
|
575
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
576
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
577
|
+
*
|
578
|
+
* @function
|
579
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setUTCHours
|
580
|
+
* @private
|
581
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
582
|
+
*/
|
583
|
+
|
584
|
+
/**
|
585
|
+
* Sets the milliseconds for the embedded date instance according to universal time.
|
586
|
+
*
|
587
|
+
* @param {int} msValue An integer representing the new milliseconds value
|
588
|
+
* @returns {int}
|
589
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
590
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
591
|
+
*
|
592
|
+
* @function
|
593
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setUTCMilliseconds
|
594
|
+
* @private
|
595
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
596
|
+
*/
|
597
|
+
|
598
|
+
/**
|
599
|
+
* Sets the minutes, seconds and milliseconds for the embedded date instance according to universal
|
600
|
+
* time.
|
601
|
+
*
|
602
|
+
* @param {int} minutesValue An integer representing the new minutes value
|
603
|
+
* @param {int} [secondsValue] An integer representing the new seconds value
|
604
|
+
* @param {int} [msValue] An integer representing the new milliseconds value
|
605
|
+
* @returns {int}
|
606
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
607
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
608
|
+
*
|
609
|
+
* @function
|
610
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setUTCMinutes
|
611
|
+
* @private
|
612
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
613
|
+
*/
|
614
|
+
|
615
|
+
/**
|
616
|
+
* Sets the month and day for the embedded date instance according to universal time and
|
617
|
+
* selected calender.
|
618
|
+
*
|
619
|
+
* @param {int} monthValue An integer representing the new month index
|
620
|
+
* @param {int} [dateValue] An integer representing the new day value
|
621
|
+
* @returns {int}
|
622
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
623
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
624
|
+
*
|
625
|
+
* @function
|
626
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setUTCMonth
|
627
|
+
* @private
|
628
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
629
|
+
*/
|
630
|
+
|
631
|
+
/**
|
632
|
+
* Sets the seconds and milliseconds for the embedded date instance according to universal time.
|
633
|
+
*
|
634
|
+
* @param {int} secondsValue An integer representing the new seconds value
|
635
|
+
* @param {int} [msValue] An integer representing the new milliseconds value
|
636
|
+
* @returns {int}
|
637
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
638
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
639
|
+
*
|
640
|
+
* @function
|
641
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setUTCSeconds
|
642
|
+
* @private
|
643
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
644
|
+
*/
|
645
|
+
|
646
|
+
/**
|
647
|
+
* Sets the year for the embedded date instance considering the configured time zone and the
|
648
|
+
* selected calender. In case of the Gregorian calendar, 1900 is added to the year value
|
649
|
+
*
|
650
|
+
* @param {int} yearValue
|
651
|
+
* An integer representing the new year value (plus 1900 for the Gregorian calendar)
|
652
|
+
* @returns {int}
|
653
|
+
* The milliseconds of the new timestamp based on the UNIX epoch, or <code>NaN</code> if the
|
654
|
+
* timestamp could not be updated. The new timestamp is a Gregorian timestamp.
|
655
|
+
*
|
656
|
+
* @deprecated for the Gregorian calendar since version 1.111.0 as it is deprecated in
|
657
|
+
* JavaScript Date, it can be used with other calendars. It still is recommended to use
|
658
|
+
* {@link #getFullYear} instead, independent on the selected calender
|
659
|
+
*
|
660
|
+
* @function
|
661
|
+
* @name sap.ui.core.date.UniversalDate.prototype.setYear
|
662
|
+
* @private
|
663
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
664
|
+
*/
|
665
|
+
|
666
|
+
/**
|
667
|
+
* Returns the date portion of the embedded date object interpreted in the configured time zone,
|
668
|
+
* independent on the selected calendar.
|
669
|
+
*
|
670
|
+
* @returns {string}
|
671
|
+
* The date portion of the embedded date object interpreted in the configured time zone
|
672
|
+
*
|
673
|
+
* @function
|
674
|
+
* @name sap.ui.core.date.UniversalDate.prototype.toDateString
|
675
|
+
* @private
|
676
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
677
|
+
*/
|
678
|
+
|
679
|
+
/**
|
680
|
+
* Returns a string representing the embedded date object interpreted in the configured time
|
681
|
+
* zone, independent on the selected calendar.
|
682
|
+
*
|
683
|
+
* @returns {string}
|
684
|
+
* A string representing the embedded date object interpreted in the configured time zone
|
685
|
+
*
|
686
|
+
* @function
|
687
|
+
* @name sap.ui.core.date.UniversalDate.prototype.toString
|
688
|
+
* @private
|
689
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
690
|
+
*/
|
691
|
+
|
692
|
+
/**
|
693
|
+
* Returns the value of the embedded date object in milliseconds based on the UNIX epoch.
|
694
|
+
*
|
695
|
+
* @returns {int} The primitive value of the embedded date object in milliseconds based on the UNIX epoch
|
696
|
+
*
|
697
|
+
* @function
|
698
|
+
* @name sap.ui.core.date.UniversalDate.prototype.valueOf
|
699
|
+
* @private
|
700
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
701
|
+
*/
|
702
|
+
["getDate", "getMonth", "getFullYear", "getYear", "getDay", "getHours", "getMinutes", "getSeconds", "getMilliseconds", "getUTCDate", "getUTCMonth", "getUTCFullYear", "getUTCDay", "getUTCHours", "getUTCMinutes", "getUTCSeconds", "getUTCMilliseconds", "getTime", "valueOf", "getTimezoneOffset", "toString", "toDateString", "setDate", "setFullYear", "setYear", "setMonth", "setHours", "setMinutes", "setSeconds", "setMilliseconds", "setUTCDate", "setUTCFullYear", "setUTCMonth", "setUTCHours", "setUTCMinutes", "setUTCSeconds", "setUTCMilliseconds"].forEach(function (sName) {
|
703
|
+
UniversalDate.prototype[sName] = function () {
|
704
|
+
return this.oDate[sName].apply(this.oDate, arguments);
|
705
|
+
};
|
109
706
|
});
|
707
|
+
|
708
|
+
/**
|
709
|
+
* Returns the date object representing the current calendar date value.
|
710
|
+
*
|
711
|
+
* @returns {Date|module:sap/ui/core/date/UI5Date} The date object representing the current calendar date value
|
712
|
+
*
|
713
|
+
* @private
|
714
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
715
|
+
*/
|
110
716
|
UniversalDate.prototype.getJSDate = function () {
|
111
|
-
|
717
|
+
return this.oDate;
|
112
718
|
};
|
719
|
+
|
720
|
+
/**
|
721
|
+
* Returns the calendar type of the current instance of a UniversalDate.
|
722
|
+
*
|
723
|
+
* @returns {sap.ui.core.CalendarType} The calendar type of the date
|
724
|
+
*
|
725
|
+
* @private
|
726
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
727
|
+
*/
|
113
728
|
UniversalDate.prototype.getCalendarType = function () {
|
114
|
-
|
729
|
+
return this.sCalendarType;
|
115
730
|
};
|
731
|
+
|
732
|
+
/**
|
733
|
+
* Returns the era index of for the embedded date instance.
|
734
|
+
*
|
735
|
+
* @returns {int} The index of the era for the embedded date instance
|
736
|
+
*
|
737
|
+
* @private
|
738
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
739
|
+
*/
|
116
740
|
UniversalDate.prototype.getEra = function () {
|
117
|
-
|
741
|
+
return UniversalDate.getEraByDate(this.sCalendarType, this.oDate.getFullYear(), this.oDate.getMonth(), this.oDate.getDate());
|
118
742
|
};
|
743
|
+
|
744
|
+
/**
|
745
|
+
* Placeholder method which is overwritten by calendar specific implementations. General usage of
|
746
|
+
* this method is to use it to set the era for the embedded date instance.
|
747
|
+
*
|
748
|
+
* @param {int} iEra
|
749
|
+
* An number representing the era index which is to be set for the embedded date instance
|
750
|
+
*
|
751
|
+
* @private
|
752
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
753
|
+
*/
|
119
754
|
UniversalDate.prototype.setEra = function (iEra) {
|
755
|
+
// The default implementation does not support setting the era
|
120
756
|
};
|
757
|
+
|
758
|
+
/**
|
759
|
+
* Returns the era index of for the embedded date instance in universal time.
|
760
|
+
*
|
761
|
+
* @returns {int} The index of the era for the embedded date instance in universal time
|
762
|
+
*
|
763
|
+
* @private
|
764
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
765
|
+
*/
|
121
766
|
UniversalDate.prototype.getUTCEra = function () {
|
122
|
-
|
767
|
+
return UniversalDate.getEraByDate(this.sCalendarType, this.oDate.getUTCFullYear(), this.oDate.getUTCMonth(), this.oDate.getUTCDate());
|
123
768
|
};
|
769
|
+
|
770
|
+
/**
|
771
|
+
* Placeholder method which is overwritten by calendar specific implementations. General usage of
|
772
|
+
* this method is to use it to set the era for the embedded date instance in universal time.
|
773
|
+
*
|
774
|
+
* @param {int} iEra
|
775
|
+
* An number representing the era index which is to be set for the embedded date instance
|
776
|
+
* in universal time
|
777
|
+
*
|
778
|
+
* @private
|
779
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
780
|
+
*/
|
124
781
|
UniversalDate.prototype.setUTCEra = function (iEra) {
|
782
|
+
// The default implementation does not support setting the era
|
125
783
|
};
|
784
|
+
|
785
|
+
/**
|
786
|
+
* Retrieves the calendar week
|
787
|
+
*
|
788
|
+
* @param {sap.ui.core.Locale} [oLocale] the locale used to get the calendar week calculation properties, defaults to the formatLocale
|
789
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} [vCalendarWeekNumbering]
|
790
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>,
|
791
|
+
* the default is derived from <code>oLocale</code> but this parameter has precedence over oLocale if both are provided.
|
792
|
+
* In case an object is provided, both properties <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code> must be set, otherwise an error is thrown.
|
793
|
+
* If calendar week numbering is not determined from the locale then {@link LocaleData#firstDayStartsFirstWeek} is ignored.
|
794
|
+
* e.g. <code>{firstDayOfWeek: 1, minimalDaysInFirstWeek: 4}</code>
|
795
|
+
* @returns {{week: int, year: int}} resulting calendar week, note: week index starts with <code>0</code>
|
796
|
+
* @private
|
797
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
798
|
+
* @throws {TypeError} If:
|
799
|
+
* <ul>
|
800
|
+
* <li>vCalendarWeekNumbering is an object and the fields <code>firstDayOfWeek</code> or <code>minimalDaysInFirstWeek</code>) are missing or have a non-numeric value</li>
|
801
|
+
* <li>vCalendarWeekNumbering is a string and has an invalid week numbering value</li>
|
802
|
+
* </ul>
|
803
|
+
*/
|
126
804
|
UniversalDate.prototype.getWeek = function (oLocale, vCalendarWeekNumbering) {
|
127
|
-
|
805
|
+
return UniversalDate.getWeekByDate(this.sCalendarType, this.getFullYear(), this.getMonth(), this.getDate(), oLocale, vCalendarWeekNumbering);
|
128
806
|
};
|
807
|
+
|
808
|
+
/**
|
809
|
+
* Sets the calendar week
|
810
|
+
*
|
811
|
+
* @param {{week: int, year: int}} oWeek the calendar week, note: week index starts with <code>0</code>,
|
812
|
+
* <code>oWeek.year</code> is optional and defaults to {@link sap.ui.core.date.UniversalDate#getFullYear}
|
813
|
+
* @param {sap.ui.core.Locale} [oLocale] the locale used to get the calendar week calculation properties, defaults to the formatLocale
|
814
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} [vCalendarWeekNumbering]
|
815
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>,
|
816
|
+
* the default is derived from <code>oLocale</code> but this parameter has precedence over oLocale if both are provided.
|
817
|
+
* In case an object is provided, both properties <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code> must be set, otherwise an error is thrown.
|
818
|
+
* If calendar week numbering is not determined from the locale then {@link LocaleData#firstDayStartsFirstWeek} is ignored.
|
819
|
+
* e.g. <code>{firstDayOfWeek: 1, minimalDaysInFirstWeek: 4}</code>
|
820
|
+
* @private
|
821
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
822
|
+
* @throws {TypeError} If:
|
823
|
+
* <ul>
|
824
|
+
* <li>vCalendarWeekNumbering is an object and the fields <code>firstDayOfWeek</code> or <code>minimalDaysInFirstWeek</code>) are missing or have a non-numeric value</li>
|
825
|
+
* <li>vCalendarWeekNumbering is a string and has an invalid week numbering value</li>
|
826
|
+
* </ul>
|
827
|
+
*/
|
129
828
|
UniversalDate.prototype.setWeek = function (oWeek, oLocale, vCalendarWeekNumbering) {
|
130
|
-
|
131
|
-
|
829
|
+
var oDate = UniversalDate.getFirstDateOfWeek(this.sCalendarType, oWeek.year || this.getFullYear(), oWeek.week, oLocale, vCalendarWeekNumbering);
|
830
|
+
this.setFullYear(oDate.year, oDate.month, oDate.day);
|
132
831
|
};
|
832
|
+
|
833
|
+
/**
|
834
|
+
* Retrieves the UTC calendar week
|
835
|
+
*
|
836
|
+
* @param {sap.ui.core.Locale} [oLocale] the locale used to get the calendar week calculation properties, defaults to the formatLocale
|
837
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} [vCalendarWeekNumbering]
|
838
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>,
|
839
|
+
* the default is derived from <code>oLocale</code> but this parameter has precedence over oLocale if both are provided.
|
840
|
+
* In case an object is provided, both properties <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code> must be set, otherwise an error is thrown.
|
841
|
+
* If calendar week numbering is not determined from the locale then {@link LocaleData#firstDayStartsFirstWeek} is ignored.
|
842
|
+
* e.g. <code>{firstDayOfWeek: 1, minimalDaysInFirstWeek: 4}</code>
|
843
|
+
* @returns {{week: int, year: int}} resulting calendar week, note: week index starts with <code>0</code>
|
844
|
+
* @private
|
845
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
846
|
+
* @throws {TypeError} If:
|
847
|
+
* <ul>
|
848
|
+
* <li>vCalendarWeekNumbering is an object and the fields <code>firstDayOfWeek</code> or <code>minimalDaysInFirstWeek</code>) are missing or have a non-numeric value</li>
|
849
|
+
* <li>vCalendarWeekNumbering is a string and has an invalid week numbering value</li>
|
850
|
+
* </ul>
|
851
|
+
*/
|
133
852
|
UniversalDate.prototype.getUTCWeek = function (oLocale, vCalendarWeekNumbering) {
|
134
|
-
|
853
|
+
return UniversalDate.getWeekByDate(this.sCalendarType, this.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate(), oLocale, vCalendarWeekNumbering);
|
135
854
|
};
|
855
|
+
|
856
|
+
/**
|
857
|
+
* Sets the UTC calendar week
|
858
|
+
*
|
859
|
+
* @param {{week: int, year: int}} oWeek the calendar week, note: week index starts with <code>0</code>,
|
860
|
+
* <code>oWeek.year</code> is optional and defaults to {@link sap.ui.core.date.UniversalDate#getFullYear}
|
861
|
+
* @param {sap.ui.core.Locale} [oLocale] the locale used to get the calendar week calculation properties, defaults to the formatLocale
|
862
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} [vCalendarWeekNumbering]
|
863
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>,
|
864
|
+
* the default is derived from <code>oLocale</code> but this parameter has precedence over oLocale if both are provided.
|
865
|
+
* In case an object is provided, both properties <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code> must be set, otherwise an error is thrown.
|
866
|
+
* If calendar week numbering is not determined from the locale then {@link LocaleData#firstDayStartsFirstWeek} is ignored.
|
867
|
+
* e.g. <code>{firstDayOfWeek: 1, minimalDaysInFirstWeek: 4}</code>
|
868
|
+
* @private
|
869
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
870
|
+
* @throws {TypeError} If:
|
871
|
+
* <ul>
|
872
|
+
* <li>vCalendarWeekNumbering is an object and the fields <code>firstDayOfWeek</code> or <code>minimalDaysInFirstWeek</code>) are missing or have a non-numeric value</li>
|
873
|
+
* <li>vCalendarWeekNumbering is a string and has an invalid week numbering value</li>
|
874
|
+
* </ul>
|
875
|
+
*/
|
136
876
|
UniversalDate.prototype.setUTCWeek = function (oWeek, oLocale, vCalendarWeekNumbering) {
|
137
|
-
|
138
|
-
|
877
|
+
var oDate = UniversalDate.getFirstDateOfWeek(this.sCalendarType, oWeek.year || this.getFullYear(), oWeek.week, oLocale, vCalendarWeekNumbering);
|
878
|
+
this.setUTCFullYear(oDate.year, oDate.month, oDate.day);
|
139
879
|
};
|
880
|
+
|
881
|
+
/**
|
882
|
+
* Returns the current quarter of the embedded date instance
|
883
|
+
*
|
884
|
+
* @returns {int} The quarter of the embedded date instance
|
885
|
+
*
|
886
|
+
* @private
|
887
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
888
|
+
*/
|
140
889
|
UniversalDate.prototype.getQuarter = function () {
|
141
|
-
|
890
|
+
return Math.floor(this.getMonth() / 3);
|
142
891
|
};
|
892
|
+
|
893
|
+
/**
|
894
|
+
* Returns the current quarter of the embedded date instance in universal time
|
895
|
+
*
|
896
|
+
* @returns {int} The quarter of the embedded date instance in universal time
|
897
|
+
*
|
898
|
+
* @private
|
899
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
900
|
+
*/
|
143
901
|
UniversalDate.prototype.getUTCQuarter = function () {
|
144
|
-
|
902
|
+
return Math.floor(this.getUTCMonth() / 3);
|
145
903
|
};
|
904
|
+
|
905
|
+
/**
|
906
|
+
* Returns an integer value depending on whether the embedded date instance time is set to the
|
907
|
+
* afternoon or morning.
|
908
|
+
*
|
909
|
+
* @returns {int}
|
910
|
+
* An integer value which indicates which day period the embedded date instance is set to. If,
|
911
|
+
* date time is set in the morning time 0 (i.e. 0:00 - 11:59) or 1 if date time is set in the
|
912
|
+
* afternoon (i.e. 12:00 - 23:59).
|
913
|
+
*
|
914
|
+
* @private
|
915
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
916
|
+
*/
|
146
917
|
UniversalDate.prototype.getDayPeriod = function () {
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
918
|
+
if (this.getHours() < 12) {
|
919
|
+
return 0;
|
920
|
+
} else {
|
921
|
+
return 1;
|
922
|
+
}
|
152
923
|
};
|
924
|
+
|
925
|
+
/**
|
926
|
+
* Returns an integer value depending on whether the embedded date instance time, is set to the
|
927
|
+
* afternoon or morning, in universal time.
|
928
|
+
*
|
929
|
+
* @returns {int}
|
930
|
+
* An integer value which indicates which day period the embedded date instance is set to, in
|
931
|
+
* universal time. If, universal date time is set in the morning time 0 (i.e. 0:00 - 11:59) or
|
932
|
+
* 1 if universal date time is set in the afternoon (i.e. 12:00 - 23:59).
|
933
|
+
*
|
934
|
+
* @private
|
935
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
936
|
+
*/
|
153
937
|
UniversalDate.prototype.getUTCDayPeriod = function () {
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
938
|
+
if (this.getUTCHours() < 12) {
|
939
|
+
return 0;
|
940
|
+
} else {
|
941
|
+
return 1;
|
942
|
+
}
|
159
943
|
};
|
944
|
+
|
945
|
+
// TODO: These are currently needed for the DateFormat test, as the date used in the test
|
946
|
+
// has been enhanced with these methods. Should be implemented using CLDR data.
|
947
|
+
/**
|
948
|
+
* Returns the short version of the time zone name of the embedded date instance.
|
949
|
+
*
|
950
|
+
* @returns {string} The short version of the name, of the time zone of the embedded date instance
|
951
|
+
*
|
952
|
+
* @private
|
953
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
954
|
+
*/
|
160
955
|
UniversalDate.prototype.getTimezoneShort = function () {
|
161
|
-
|
162
|
-
|
163
|
-
|
956
|
+
if (this.oDate.getTimezoneShort) {
|
957
|
+
return this.oDate.getTimezoneShort();
|
958
|
+
}
|
164
959
|
};
|
960
|
+
|
961
|
+
/**
|
962
|
+
* Returns the long version of the time zone name of the embedded date instance.
|
963
|
+
*
|
964
|
+
* @returns {string} The long version of the name, of the time zone of the embedded date instance
|
965
|
+
*
|
966
|
+
* @private
|
967
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
968
|
+
*/
|
165
969
|
UniversalDate.prototype.getTimezoneLong = function () {
|
166
|
-
|
167
|
-
|
168
|
-
|
970
|
+
if (this.oDate.getTimezoneLong) {
|
971
|
+
return this.oDate.getTimezoneLong();
|
972
|
+
}
|
169
973
|
};
|
974
|
+
|
975
|
+
/*
|
976
|
+
* Helper methods for week calculations
|
977
|
+
*/
|
170
978
|
var iMillisecondsInWeek = 7 * 24 * 60 * 60 * 1000;
|
979
|
+
|
980
|
+
/**
|
981
|
+
* Retrieves the calendar week for a given date, specified by year, month, and day.
|
982
|
+
*
|
983
|
+
* @param {string} sCalendarType the calendar type, e.g. <code>"Gregorian"</code>
|
984
|
+
* @param {int} iYear year, e.g. <code>2016</code>
|
985
|
+
* @param {int} iMonth the month, e.g. <code>2</code>
|
986
|
+
* @param {int} iDay the date, e.g. <code>3</code>
|
987
|
+
* @param {sap.ui.core.Locale} [oLocale] the locale used for the week calculation, if oWeekConfig is not provided (falls back to the formatLocale)
|
988
|
+
* e.g. <code>new Locale("de-DE")</code>
|
989
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} [vCalendarWeekNumbering]
|
990
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>,
|
991
|
+
* the default is derived from <code>oLocale</code> but this parameter has precedence over oLocale if both are provided.
|
992
|
+
* In case an object is provided, both properties <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code> must be set, otherwise an error is thrown.
|
993
|
+
* If calendar week numbering is not determined from the locale then {@link LocaleData#firstDayStartsFirstWeek} is ignored.
|
994
|
+
* e.g. <code>{firstDayOfWeek: 1, minimalDaysInFirstWeek: 4}</code>
|
995
|
+
* @returns {{week: int, year: int}} resulting calendar week, note: week index starts with <code>0</code>, e.g. <code>{year: 2016, week: 8}</code>
|
996
|
+
* @private
|
997
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
998
|
+
* @throws {TypeError} If:
|
999
|
+
* <ul>
|
1000
|
+
* <li>vCalendarWeekNumbering is an object and the fields <code>firstDayOfWeek</code> or <code>minimalDaysInFirstWeek</code>) are missing or have a non-numeric value</li>
|
1001
|
+
* <li>vCalendarWeekNumbering is a string and has an invalid week numbering value</li>
|
1002
|
+
* </ul>
|
1003
|
+
*/
|
171
1004
|
UniversalDate.getWeekByDate = function (sCalendarType, iYear, iMonth, iDay, oLocale, vCalendarWeekNumbering) {
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
1005
|
+
vCalendarWeekNumbering = vCalendarWeekNumbering || Configuration.getCalendarWeekNumbering();
|
1006
|
+
checkWeekConfig(vCalendarWeekNumbering);
|
1007
|
+
oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
|
1008
|
+
var clDate = this.getClass(sCalendarType);
|
1009
|
+
var oFirstDay = getFirstDayOfFirstWeek(clDate, iYear, oLocale, vCalendarWeekNumbering);
|
1010
|
+
var oDate = new clDate(clDate.UTC(iYear, iMonth, iDay));
|
1011
|
+
var iWeek, iLastYear, iNextYear, oLastFirstDay, oNextFirstDay;
|
1012
|
+
var bSplitWeek = isSplitWeek(vCalendarWeekNumbering, oLocale);
|
1013
|
+
if (bSplitWeek) {
|
1014
|
+
iWeek = calculateWeeks(oFirstDay, oDate);
|
1015
|
+
} else {
|
1016
|
+
iLastYear = iYear - 1;
|
1017
|
+
iNextYear = iYear + 1;
|
1018
|
+
oLastFirstDay = getFirstDayOfFirstWeek(clDate, iLastYear, oLocale, vCalendarWeekNumbering);
|
1019
|
+
oNextFirstDay = getFirstDayOfFirstWeek(clDate, iNextYear, oLocale, vCalendarWeekNumbering);
|
1020
|
+
if (oDate >= oNextFirstDay) {
|
1021
|
+
iYear = iNextYear;
|
1022
|
+
iWeek = 0;
|
1023
|
+
} else if (oDate < oFirstDay) {
|
1024
|
+
iYear = iLastYear;
|
1025
|
+
iWeek = calculateWeeks(oLastFirstDay, oDate);
|
182
1026
|
} else {
|
183
|
-
|
184
|
-
iNextYear = iYear + 1;
|
185
|
-
oLastFirstDay = getFirstDayOfFirstWeek(clDate, iLastYear, oLocale, vCalendarWeekNumbering);
|
186
|
-
oNextFirstDay = getFirstDayOfFirstWeek(clDate, iNextYear, oLocale, vCalendarWeekNumbering);
|
187
|
-
if (oDate >= oNextFirstDay) {
|
188
|
-
iYear = iNextYear;
|
189
|
-
iWeek = 0;
|
190
|
-
} else if (oDate < oFirstDay) {
|
191
|
-
iYear = iLastYear;
|
192
|
-
iWeek = calculateWeeks(oLastFirstDay, oDate);
|
193
|
-
} else {
|
194
|
-
iWeek = calculateWeeks(oFirstDay, oDate);
|
195
|
-
}
|
1027
|
+
iWeek = calculateWeeks(oFirstDay, oDate);
|
196
1028
|
}
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
1029
|
+
}
|
1030
|
+
return {
|
1031
|
+
year: iYear,
|
1032
|
+
week: iWeek
|
1033
|
+
};
|
201
1034
|
};
|
1035
|
+
|
1036
|
+
/**
|
1037
|
+
* Retrieves the first day's date of the given week in the given year.
|
1038
|
+
*
|
1039
|
+
* @param {string} sCalendarType the calendar type, e.g. <code>"Gregorian"</code>
|
1040
|
+
* @param {int} iYear year, e.g. <code>2016</code>
|
1041
|
+
* @param {int} iWeek the calendar week index, e.g. <code>8</code>
|
1042
|
+
* @param {sap.ui.core.Locale} [oLocale] the locale used for the week calculation, if oWeekConfig is not provided (falls back to the formatLocale)
|
1043
|
+
* e.g. <code>new Locale("de-DE")</code>
|
1044
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} [vCalendarWeekNumbering]
|
1045
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>,
|
1046
|
+
* the default is derived from <code>oLocale</code> but this parameter has precedence over oLocale if both are provided.
|
1047
|
+
* In case an object is provided, both properties <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code> must be set, otherwise an error is thrown.
|
1048
|
+
* If calendar week numbering is not determined from the locale then {@link LocaleData#firstDayStartsFirstWeek} is ignored.
|
1049
|
+
* e.g. <code>{firstDayOfWeek: 1, minimalDaysInFirstWeek: 4}</code>
|
1050
|
+
* @returns {{month: int, year: int, day: int}} the resulting date, e.g. <code>{year: 2016, month: 1, day: 29}</code>
|
1051
|
+
* @private
|
1052
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
1053
|
+
* @throws {TypeError} If:
|
1054
|
+
* <ul>
|
1055
|
+
* <li>vCalendarWeekNumbering is an object and the fields <code>firstDayOfWeek</code> or <code>minimalDaysInFirstWeek</code>) are missing or have a non-numeric value</li>
|
1056
|
+
* <li>vCalendarWeekNumbering is a string and has an invalid week numbering value</li>
|
1057
|
+
* </ul>
|
1058
|
+
*/
|
202
1059
|
UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek, oLocale, vCalendarWeekNumbering) {
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
return {
|
212
|
-
year: iYear,
|
213
|
-
month: 0,
|
214
|
-
day: 1
|
215
|
-
};
|
216
|
-
}
|
1060
|
+
vCalendarWeekNumbering = vCalendarWeekNumbering || Configuration.getCalendarWeekNumbering();
|
1061
|
+
checkWeekConfig(vCalendarWeekNumbering);
|
1062
|
+
oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
|
1063
|
+
var clDate = this.getClass(sCalendarType);
|
1064
|
+
var oFirstDay = getFirstDayOfFirstWeek(clDate, iYear, oLocale, vCalendarWeekNumbering);
|
1065
|
+
var oDate = new clDate(oFirstDay.valueOf() + iWeek * iMillisecondsInWeek);
|
1066
|
+
var bSplitWeek = isSplitWeek(vCalendarWeekNumbering, oLocale);
|
1067
|
+
if (bSplitWeek && iWeek === 0 && oFirstDay.getUTCFullYear() < iYear) {
|
217
1068
|
return {
|
218
|
-
|
219
|
-
|
220
|
-
|
1069
|
+
year: iYear,
|
1070
|
+
month: 0,
|
1071
|
+
day: 1
|
221
1072
|
};
|
1073
|
+
}
|
1074
|
+
return {
|
1075
|
+
year: oDate.getUTCFullYear(),
|
1076
|
+
month: oDate.getUTCMonth(),
|
1077
|
+
day: oDate.getUTCDate()
|
1078
|
+
};
|
222
1079
|
};
|
1080
|
+
|
1081
|
+
/**
|
1082
|
+
* Determines if the split week algorithm should be applied (the first day of the first calendar
|
1083
|
+
* week of the year is January 1st).
|
1084
|
+
*
|
1085
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} vCalendarWeekNumbering
|
1086
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and
|
1087
|
+
* <code>minimalDaysInFirstWeek</code>
|
1088
|
+
* @param {sap.ui.core.Locale} oLocale the locale used for the week calculation
|
1089
|
+
* @returns {boolean} if the split week should be applied
|
1090
|
+
*/
|
223
1091
|
function isSplitWeek(vCalendarWeekNumbering, oLocale) {
|
224
|
-
|
225
|
-
|
1092
|
+
var oLocaleData = LocaleData.getInstance(oLocale);
|
1093
|
+
|
1094
|
+
// only applies for en_US with default CalendarWeekNumbering (WesternTraditional is default in en_US)
|
1095
|
+
return (vCalendarWeekNumbering === CalendarWeekNumbering.Default || vCalendarWeekNumbering === CalendarWeekNumbering.WesternTraditional) && oLocaleData.firstDayStartsFirstWeek();
|
226
1096
|
}
|
1097
|
+
|
1098
|
+
/**
|
1099
|
+
* Checks the calendar week configuration
|
1100
|
+
*
|
1101
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} vCalendarWeekNumbering
|
1102
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>
|
1103
|
+
* @throws {TypeError} If:
|
1104
|
+
* <ul>
|
1105
|
+
* <li>vCalendarWeekNumbering is an object and the fields <code>firstDayOfWeek</code> or <code>minimalDaysInFirstWeek</code>) are missing or have a non-numeric value</li>
|
1106
|
+
* <li>vCalendarWeekNumbering is a string and has an invalid week numbering value</li>
|
1107
|
+
* </ul>
|
1108
|
+
*/
|
227
1109
|
function checkWeekConfig(vCalendarWeekNumbering) {
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
}
|
232
|
-
} else if (!Object.values(CalendarWeekNumbering).includes(vCalendarWeekNumbering)) {
|
233
|
-
throw new TypeError('Illegal format option calendarWeekNumbering: \'' + vCalendarWeekNumbering + '\'');
|
1110
|
+
if (typeof vCalendarWeekNumbering === "object") {
|
1111
|
+
if (typeof vCalendarWeekNumbering.firstDayOfWeek !== "number" || typeof vCalendarWeekNumbering.minimalDaysInFirstWeek !== "number") {
|
1112
|
+
throw new TypeError("Week config requires firstDayOfWeek and minimalDaysInFirstWeek to be set");
|
234
1113
|
}
|
1114
|
+
} else if (!Object.values(CalendarWeekNumbering).includes(vCalendarWeekNumbering)) {
|
1115
|
+
throw new TypeError("Illegal format option calendarWeekNumbering: '" + vCalendarWeekNumbering + "'");
|
1116
|
+
}
|
235
1117
|
}
|
1118
|
+
|
1119
|
+
/**
|
1120
|
+
* Resolves the calendar week configuration
|
1121
|
+
*
|
1122
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} vCalendarWeekNumbering
|
1123
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>
|
1124
|
+
* @param {sap.ui.core.Locale} [oLocale] locale to be used
|
1125
|
+
* @returns {{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} calendar week calculation configuration
|
1126
|
+
*/
|
236
1127
|
function resolveCalendarWeekConfiguration(vCalendarWeekNumbering, oLocale) {
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
1128
|
+
// be backward compatible
|
1129
|
+
if (typeof vCalendarWeekNumbering === "object" && typeof vCalendarWeekNumbering.firstDayOfWeek === "number" && typeof vCalendarWeekNumbering.minimalDaysInFirstWeek === "number") {
|
1130
|
+
return vCalendarWeekNumbering;
|
1131
|
+
}
|
1132
|
+
return CalendarUtils.getWeekConfigurationValues(vCalendarWeekNumbering, oLocale);
|
241
1133
|
}
|
1134
|
+
|
1135
|
+
/**
|
1136
|
+
* Returns the first day of the first week in the given year.
|
1137
|
+
*
|
1138
|
+
* @param {UniversalDate} clDate the date class
|
1139
|
+
* @param {int} iYear year, e.g. <code>2016</code>
|
1140
|
+
* @param {sap.ui.core.Locale} [oLocale] the locale used for the week calculation, if oWeekConfig is not provided (falls back to the formatLocale)
|
1141
|
+
* e.g. <code>new Locale("de-DE")</code>
|
1142
|
+
* @param {sap.ui.core.date.CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}} vCalendarWeekNumbering
|
1143
|
+
* calendar week numbering or object with fields <code>firstDayOfWeek</code> and <code>minimalDaysInFirstWeek</code>,
|
1144
|
+
* the default is derived from <code>oLocale</code> but this parameter has precedence over oLocale if both are provided.
|
1145
|
+
* e.g. <code>{firstDayOfWeek: 1, minimalDaysInFirstWeek: 4}</code>
|
1146
|
+
* @returns {Date} first day of the first week in the given year, e.g. <code>Mon Jan 04 2016 01:00:00 GMT+0100</code>
|
1147
|
+
*/
|
242
1148
|
function getFirstDayOfFirstWeek(clDate, iYear, oLocale, vCalendarWeekNumbering) {
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
1149
|
+
oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
|
1150
|
+
var oWeekConfig = resolveCalendarWeekConfiguration(vCalendarWeekNumbering, oLocale);
|
1151
|
+
var iMinDays = oWeekConfig.minimalDaysInFirstWeek;
|
1152
|
+
var iFirstDayOfWeek = oWeekConfig.firstDayOfWeek;
|
1153
|
+
var oFirstDay = new clDate(clDate.UTC(iYear, 0, 1));
|
1154
|
+
var iDayCount = 7;
|
1155
|
+
if (isNaN(oFirstDay.getTime())) {
|
1156
|
+
throw new Error("Could not determine the first day of the week, because the date " + "object is invalid");
|
1157
|
+
}
|
1158
|
+
// Find the first day of the first week of the year
|
1159
|
+
while (oFirstDay.getUTCDay() !== iFirstDayOfWeek) {
|
1160
|
+
oFirstDay.setUTCDate(oFirstDay.getUTCDate() - 1);
|
1161
|
+
iDayCount--;
|
1162
|
+
}
|
1163
|
+
// If less than min days are left, first week is one week later
|
1164
|
+
if (iDayCount < iMinDays) {
|
1165
|
+
oFirstDay.setUTCDate(oFirstDay.getUTCDate() + 7);
|
1166
|
+
}
|
1167
|
+
return oFirstDay;
|
260
1168
|
}
|
1169
|
+
|
1170
|
+
/**
|
1171
|
+
* Returns the rounded amount of weeks a given time frame.
|
1172
|
+
*
|
1173
|
+
* @param {Date} oFromDate The beginning date of the time interval
|
1174
|
+
* @param {Date} oToDate The end date of the time interval
|
1175
|
+
* @returns {int} A rounded number which represents the amount of weeks in the given timer interval
|
1176
|
+
*/
|
261
1177
|
function calculateWeeks(oFromDate, oToDate) {
|
262
|
-
|
1178
|
+
return Math.floor((oToDate.valueOf() - oFromDate.valueOf()) / iMillisecondsInWeek);
|
263
1179
|
}
|
1180
|
+
|
1181
|
+
/*
|
1182
|
+
* Helper methods for era calculations
|
1183
|
+
*/
|
264
1184
|
var mEras = {};
|
1185
|
+
|
1186
|
+
/**
|
1187
|
+
* Returns an index of the era for the given date values in the given calender. For
|
1188
|
+
* an index to be returned the date value has to be within the era time period, i.e. the
|
1189
|
+
* timestamp value of the date has to be bigger or equal than the start timestamp of the era
|
1190
|
+
* or smaller than the end of the end period.
|
1191
|
+
*
|
1192
|
+
* @param {string} sCalendarType The given calender type which the eras available for selection
|
1193
|
+
* @param {int} iYear The year value for which the era is looked for
|
1194
|
+
* @param {int} iMonth The month value for which the era is looked for
|
1195
|
+
* @param {int} iDay The date value for which the era is looked for
|
1196
|
+
* @returns {int} The index of the found era for the given date values in the given calender
|
1197
|
+
*
|
1198
|
+
* @private
|
1199
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
1200
|
+
*/
|
265
1201
|
UniversalDate.getEraByDate = function (sCalendarType, iYear, iMonth, iDay) {
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
}
|
1202
|
+
var aEras = getEras(sCalendarType),
|
1203
|
+
// no need to use UI5Date.getInstance as only the UTC timestamp is used
|
1204
|
+
iTimestamp = new Date(0).setUTCFullYear(iYear, iMonth, iDay),
|
1205
|
+
oEra;
|
1206
|
+
for (var i = aEras.length - 1; i >= 0; i--) {
|
1207
|
+
oEra = aEras[i];
|
1208
|
+
if (!oEra) {
|
1209
|
+
continue;
|
1210
|
+
}
|
1211
|
+
if (oEra._start && iTimestamp >= oEra._startInfo.timestamp) {
|
1212
|
+
return i;
|
278
1213
|
}
|
1214
|
+
if (oEra._end && iTimestamp < oEra._endInfo.timestamp) {
|
1215
|
+
return i;
|
1216
|
+
}
|
1217
|
+
}
|
279
1218
|
};
|
1219
|
+
|
1220
|
+
/**
|
1221
|
+
* Returns an index of the current era for the embedded date instance.
|
1222
|
+
*
|
1223
|
+
* @param {string} sCalendarType The calender type which defines the available eras to select from
|
1224
|
+
* @returns {int} The index of the current era of the embedded date instance
|
1225
|
+
*
|
1226
|
+
* @private
|
1227
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
1228
|
+
*/
|
280
1229
|
UniversalDate.getCurrentEra = function (sCalendarType) {
|
281
|
-
|
282
|
-
|
1230
|
+
var oNow = UI5Date.getInstance();
|
1231
|
+
return this.getEraByDate(sCalendarType, oNow.getFullYear(), oNow.getMonth(), oNow.getDate());
|
283
1232
|
};
|
1233
|
+
|
1234
|
+
/**
|
1235
|
+
* Returns the start date of the selected era from the given era index, in the given calender type.
|
1236
|
+
*
|
1237
|
+
* @param {string} sCalendarType The calender type from which the era is to be picked
|
1238
|
+
* @param {int} iEra The given era index of the to be selected era
|
1239
|
+
* @returns {object|null}
|
1240
|
+
* The start date object of the selected era. If no era can be found for the given index the first
|
1241
|
+
* era of the selected calender is chosen. If the chosen era does not have a start date defined
|
1242
|
+
* <code>null</code>
|
1243
|
+
*
|
1244
|
+
* @private
|
1245
|
+
* @ui5-restricted SAPUI5 Distribution Layer Libraries
|
1246
|
+
*/
|
284
1247
|
UniversalDate.getEraStartDate = function (sCalendarType, iEra) {
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
1248
|
+
var aEras = getEras(sCalendarType),
|
1249
|
+
oEra = aEras[iEra] || aEras[0];
|
1250
|
+
if (oEra._start) {
|
1251
|
+
return oEra._startInfo;
|
1252
|
+
}
|
289
1253
|
};
|
1254
|
+
|
1255
|
+
/**
|
1256
|
+
* Returns an array of era for the given calender.
|
1257
|
+
*
|
1258
|
+
* @param {string} sCalendarType
|
1259
|
+
* The calender type from which the the locale era data is taken from and the era array is
|
1260
|
+
* generated
|
1261
|
+
* @returns {array} An array of all available era in the given calender
|
1262
|
+
*/
|
290
1263
|
function getEras(sCalendarType) {
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
}
|
302
|
-
if (oEra._start) {
|
303
|
-
oEra._startInfo = parseDateString(oEra._start);
|
304
|
-
}
|
305
|
-
if (oEra._end) {
|
306
|
-
oEra._endInfo = parseDateString(oEra._end);
|
307
|
-
}
|
308
|
-
}
|
309
|
-
mEras[sCalendarType] = aEras;
|
1264
|
+
var oLocale = Configuration.getFormatSettings().getFormatLocale(),
|
1265
|
+
oLocaleData = LocaleData.getInstance(oLocale),
|
1266
|
+
aEras = mEras[sCalendarType];
|
1267
|
+
if (!aEras) {
|
1268
|
+
// Get eras from localedata, parse it and add it to the array
|
1269
|
+
var aEras = oLocaleData.getEraDates(sCalendarType);
|
1270
|
+
if (!aEras[0]) {
|
1271
|
+
aEras[0] = {
|
1272
|
+
_start: "1-1-1"
|
1273
|
+
};
|
310
1274
|
}
|
311
|
-
|
1275
|
+
for (var i = 0; i < aEras.length; i++) {
|
1276
|
+
var oEra = aEras[i];
|
1277
|
+
if (!oEra) {
|
1278
|
+
continue;
|
1279
|
+
}
|
1280
|
+
if (oEra._start) {
|
1281
|
+
oEra._startInfo = parseDateString(oEra._start);
|
1282
|
+
}
|
1283
|
+
if (oEra._end) {
|
1284
|
+
oEra._endInfo = parseDateString(oEra._end);
|
1285
|
+
}
|
1286
|
+
}
|
1287
|
+
mEras[sCalendarType] = aEras;
|
1288
|
+
}
|
1289
|
+
return aEras;
|
312
1290
|
}
|
1291
|
+
|
1292
|
+
/**
|
1293
|
+
* Returns an object containing the date parts year, month, day of month and the date timestamp value
|
1294
|
+
* of the given date string.
|
1295
|
+
*
|
1296
|
+
* @param {string} sDateString The date string which is to be parsed
|
1297
|
+
* @returns {object}
|
1298
|
+
* An object containing the year, month, day of month and date timestamp values of the given
|
1299
|
+
* date string
|
1300
|
+
*/
|
313
1301
|
function parseDateString(sDateString) {
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
1302
|
+
var aParts = sDateString.split("-"),
|
1303
|
+
iYear,
|
1304
|
+
iMonth,
|
1305
|
+
iDay;
|
1306
|
+
if (aParts[0] == "") {
|
1307
|
+
// negative year
|
1308
|
+
iYear = -parseInt(aParts[1]);
|
1309
|
+
iMonth = parseInt(aParts[2]) - 1;
|
1310
|
+
iDay = parseInt(aParts[3]);
|
1311
|
+
} else {
|
1312
|
+
iYear = parseInt(aParts[0]);
|
1313
|
+
iMonth = parseInt(aParts[1]) - 1;
|
1314
|
+
iDay = parseInt(aParts[2]);
|
1315
|
+
}
|
1316
|
+
return {
|
1317
|
+
// no need to use UI5Date.getInstance as only the UTC timestamp is used
|
1318
|
+
timestamp: new Date(0).setUTCFullYear(iYear, iMonth, iDay),
|
1319
|
+
year: iYear,
|
1320
|
+
month: iMonth,
|
1321
|
+
day: iDay
|
1322
|
+
};
|
330
1323
|
}
|
331
1324
|
export default UniversalDate;
|