@ui5/webcomponents-localization 1.22.0-rc.0 → 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 +16 -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/tsconfig.json +2 -1
- package/used-modules.txt +20 -1
- package/dist/sap/ui/Device.js +0 -5
@@ -1,305 +1,991 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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.3
|
68
|
+
*/
|
44
69
|
function UI5Date(vDateParts, sTimezoneID) {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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, {
|
73
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
213
|
-
|
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
|
-
|
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
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
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
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
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
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
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
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
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
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
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
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
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
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
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
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
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
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
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;
|