@ui5/webcomponents-localization 0.0.0-de4752078 → 0.0.0-e58530409
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 +137 -0
- package/README.md +36 -6
- package/dist/dates/CalendarDate.js +7 -1
- package/dist/generated/assets/cldr/en.json +1 -0
- package/dist/generated/assets/cldr/en_AU.json +1 -1
- package/dist/generated/json-imports/LocaleData-static.js +2 -1
- package/dist/generated/json-imports/LocaleData.js +2 -1
- package/dist/sap/base/Log.js +2 -10
- package/dist/sap/base/assert.js +1 -5
- package/dist/sap/base/util/deepEqual.js +1 -5
- package/dist/sap/ui/base/Interface.js +1 -3
- package/dist/sap/ui/base/Object.js +26 -2
- package/dist/sap/ui/core/Core.js +2 -0
- package/dist/sap/ui/core/Locale.js +12 -0
- package/dist/sap/ui/core/LocaleData.js +32 -1501
- package/dist/sap/ui/core/date/UniversalDate.js +10 -4
- package/dist/sap/ui/core/format/DateFormat.js +369 -170
- package/dist/sap/ui/core/format/TimezoneUtil.js +83 -0
- package/package-scripts.js +7 -9
- package/package.json +11 -14
- package/src/dates/CalendarDate.js +7 -1
- package/src/sap/ui/core/Core.js +2 -0
- package/used-modules.txt +1 -0
- package/hash.txt +0 -1
@@ -42,6 +42,9 @@ UniversalDate.getInstance = function (oDate, sCalendarType) {
|
|
42
42
|
} else if (!oDate) {
|
43
43
|
oDate = new Date();
|
44
44
|
}
|
45
|
+
if (isNaN(oDate.getTime())) {
|
46
|
+
throw new Error('The given date object is invalid');
|
47
|
+
}
|
45
48
|
if (!sCalendarType) {
|
46
49
|
sCalendarType = Core.getConfiguration().getCalendarType();
|
47
50
|
}
|
@@ -162,8 +165,8 @@ UniversalDate.prototype.getTimezoneLong = function () {
|
|
162
165
|
};
|
163
166
|
var iMillisecondsInWeek = 7 * 24 * 60 * 60 * 1000;
|
164
167
|
UniversalDate.getWeekByDate = function (sCalendarType, iYear, iMonth, iDay) {
|
165
|
-
var oLocale = Core.getConfiguration().getFormatSettings().getFormatLocale(), clDate = this.getClass(sCalendarType), oFirstDay = getFirstDayOfFirstWeek(clDate, iYear), oDate = new clDate(clDate.UTC(iYear, iMonth, iDay)), iWeek, iLastYear, iNextYear, oLastFirstDay, oNextFirstDay;
|
166
|
-
if (
|
168
|
+
var oLocale = Core.getConfiguration().getFormatSettings().getFormatLocale(), oLocaleData = LocaleData.getInstance(oLocale), clDate = this.getClass(sCalendarType), oFirstDay = getFirstDayOfFirstWeek(clDate, iYear), oDate = new clDate(clDate.UTC(iYear, iMonth, iDay)), iWeek, iLastYear, iNextYear, oLastFirstDay, oNextFirstDay;
|
169
|
+
if (oLocaleData.firstDayStartsFirstWeek()) {
|
167
170
|
iWeek = calculateWeeks(oFirstDay, oDate);
|
168
171
|
} else {
|
169
172
|
iLastYear = iYear - 1;
|
@@ -186,8 +189,8 @@ UniversalDate.getWeekByDate = function (sCalendarType, iYear, iMonth, iDay) {
|
|
186
189
|
};
|
187
190
|
};
|
188
191
|
UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek) {
|
189
|
-
var oLocale = Core.getConfiguration().getFormatSettings().getFormatLocale(), clDate = this.getClass(sCalendarType), oFirstDay = getFirstDayOfFirstWeek(clDate, iYear), oDate = new clDate(oFirstDay.valueOf() + iWeek * iMillisecondsInWeek);
|
190
|
-
if (
|
192
|
+
var oLocale = Core.getConfiguration().getFormatSettings().getFormatLocale(), oLocaleData = LocaleData.getInstance(oLocale), clDate = this.getClass(sCalendarType), oFirstDay = getFirstDayOfFirstWeek(clDate, iYear), oDate = new clDate(oFirstDay.valueOf() + iWeek * iMillisecondsInWeek), bIsRegionUS = oLocaleData.firstDayStartsFirstWeek();
|
193
|
+
if (bIsRegionUS && iWeek === 0 && oFirstDay.getUTCFullYear() < iYear) {
|
191
194
|
return {
|
192
195
|
year: iYear,
|
193
196
|
month: 0,
|
@@ -202,6 +205,9 @@ UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek) {
|
|
202
205
|
};
|
203
206
|
function getFirstDayOfFirstWeek(clDate, iYear) {
|
204
207
|
var oLocale = Core.getConfiguration().getFormatSettings().getFormatLocale(), oLocaleData = LocaleData.getInstance(oLocale), iMinDays = oLocaleData.getMinimalDaysInFirstWeek(), iFirstDayOfWeek = oLocaleData.getFirstDayOfWeek(), oFirstDay = new clDate(clDate.UTC(iYear, 0, 1)), iDayCount = 7;
|
208
|
+
if (isNaN(oFirstDay.getTime())) {
|
209
|
+
throw new Error('Could not determine the first day of the week, because the date ' + 'object is invalid');
|
210
|
+
}
|
205
211
|
while (oFirstDay.getUTCDay() !== iFirstDayOfWeek) {
|
206
212
|
oFirstDay.setUTCDate(oFirstDay.getUTCDate() - 1);
|
207
213
|
iDayCount--;
|