@ui5/webcomponents-localization 1.9.2 → 1.10.0
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/dist/Assets-static.d.ts +1 -0
- package/dist/Assets-static.js +1 -0
- package/dist/Assets-static.js.map +1 -0
- package/dist/Assets.d.ts +1 -0
- package/dist/Assets.js +1 -0
- package/dist/Assets.js.map +1 -0
- package/dist/DateFormat.d.ts +6 -0
- package/dist/DateFormat.js +6 -2
- package/dist/DateFormat.js.map +1 -0
- package/dist/LocaleData.d.ts +6 -0
- package/dist/LocaleData.js +6 -2
- package/dist/LocaleData.js.map +1 -0
- package/dist/dates/CalendarDate.d.ts +41 -0
- package/dist/dates/CalendarDate.js +170 -207
- package/dist/dates/CalendarDate.js.map +1 -0
- package/dist/dates/ExtremeDates.d.ts +5 -0
- package/dist/dates/ExtremeDates.js +25 -35
- package/dist/dates/ExtremeDates.js.map +1 -0
- package/dist/dates/UniversalDate.d.ts +46 -0
- package/dist/dates/UniversalDate.js +5 -0
- package/dist/dates/UniversalDate.js.map +1 -0
- package/dist/dates/calculateWeekNumber.d.ts +4 -0
- package/dist/dates/calculateWeekNumber.js +42 -48
- package/dist/dates/calculateWeekNumber.js.map +1 -0
- package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
- package/dist/dates/convertMonthNumbersToMonthNames.js +15 -18
- package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
- package/dist/dates/getDaysInMonth.d.ts +3 -0
- package/dist/dates/getDaysInMonth.js +7 -8
- package/dist/dates/getDaysInMonth.js.map +1 -0
- package/dist/dates/getRoundedTimestamp.d.ts +7 -0
- package/dist/dates/getRoundedTimestamp.js +9 -9
- package/dist/dates/getRoundedTimestamp.js.map +1 -0
- package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
- package/dist/dates/getTodayUTCTimestamp.js +2 -3
- package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
- package/dist/dates/modifyDateBy.d.ts +13 -0
- package/dist/dates/modifyDateBy.js +27 -29
- package/dist/dates/modifyDateBy.js.map +1 -0
- package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
- package/dist/dates/transformDateToSecondaryType.js +12 -15
- package/dist/dates/transformDateToSecondaryType.js.map +1 -0
- package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
- package/dist/features/calendar/Buddhist.js +1 -0
- package/dist/features/calendar/Buddhist.js.map +1 -0
- package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
- package/dist/features/calendar/Gregorian.js +1 -0
- package/dist/features/calendar/Gregorian.js.map +1 -0
- package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
- package/dist/features/calendar/Islamic.js +1 -0
- package/dist/features/calendar/Islamic.js.map +1 -0
- package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
- package/dist/features/calendar/Japanese.js +1 -0
- package/dist/features/calendar/Japanese.js.map +1 -0
- package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
- package/dist/features/calendar/Persian.js +1 -0
- package/dist/features/calendar/Persian.js.map +1 -0
- package/dist/generated/assets/cldr/ar.json +799 -1
- package/dist/generated/assets/cldr/ar_EG.json +799 -1
- package/dist/generated/assets/cldr/ar_SA.json +799 -1
- package/dist/generated/assets/cldr/bg.json +764 -1
- package/dist/generated/assets/cldr/ca.json +798 -1
- package/dist/generated/assets/cldr/cs.json +797 -1
- package/dist/generated/assets/cldr/cy.json +729 -1
- package/dist/generated/assets/cldr/da.json +764 -1
- package/dist/generated/assets/cldr/de.json +798 -1
- package/dist/generated/assets/cldr/de_AT.json +798 -1
- package/dist/generated/assets/cldr/de_CH.json +798 -1
- package/dist/generated/assets/cldr/el.json +697 -1
- package/dist/generated/assets/cldr/el_CY.json +697 -1
- package/dist/generated/assets/cldr/en.json +763 -2
- package/dist/generated/assets/cldr/en_AU.json +763 -1
- package/dist/generated/assets/cldr/en_GB.json +763 -1
- package/dist/generated/assets/cldr/en_HK.json +763 -1
- package/dist/generated/assets/cldr/en_IE.json +763 -1
- package/dist/generated/assets/cldr/en_IN.json +763 -1
- package/dist/generated/assets/cldr/en_NZ.json +763 -1
- package/dist/generated/assets/cldr/en_PG.json +763 -1
- package/dist/generated/assets/cldr/en_SG.json +763 -1
- package/dist/generated/assets/cldr/en_ZA.json +763 -1
- package/dist/generated/assets/cldr/es.json +730 -1
- package/dist/generated/assets/cldr/es_AR.json +730 -1
- package/dist/generated/assets/cldr/es_BO.json +733 -4
- package/dist/generated/assets/cldr/es_CL.json +733 -4
- package/dist/generated/assets/cldr/es_CO.json +730 -1
- package/dist/generated/assets/cldr/es_MX.json +733 -4
- package/dist/generated/assets/cldr/es_PE.json +733 -4
- package/dist/generated/assets/cldr/es_UY.json +733 -4
- package/dist/generated/assets/cldr/es_VE.json +732 -3
- package/dist/generated/assets/cldr/et.json +763 -1
- package/dist/generated/assets/cldr/fa.json +765 -1
- package/dist/generated/assets/cldr/fi.json +797 -1
- package/dist/generated/assets/cldr/fr.json +763 -1
- package/dist/generated/assets/cldr/fr_BE.json +763 -1
- package/dist/generated/assets/cldr/fr_CA.json +763 -1
- package/dist/generated/assets/cldr/fr_CH.json +763 -1
- package/dist/generated/assets/cldr/fr_LU.json +763 -1
- package/dist/generated/assets/cldr/he.json +798 -1
- package/dist/generated/assets/cldr/hi.json +730 -1
- package/dist/generated/assets/cldr/hr.json +763 -1
- package/dist/generated/assets/cldr/hu.json +831 -1
- package/dist/generated/assets/cldr/id.json +763 -1
- package/dist/generated/assets/cldr/it.json +763 -1
- package/dist/generated/assets/cldr/it_CH.json +763 -1
- package/dist/generated/assets/cldr/ja.json +797 -1
- package/dist/generated/assets/cldr/kk.json +763 -1
- package/dist/generated/assets/cldr/ko.json +797 -1
- package/dist/generated/assets/cldr/lt.json +763 -1
- package/dist/generated/assets/cldr/lv.json +763 -1
- package/dist/generated/assets/cldr/ms.json +731 -1
- package/dist/generated/assets/cldr/nb.json +764 -1
- package/dist/generated/assets/cldr/nl.json +730 -1
- package/dist/generated/assets/cldr/nl_BE.json +730 -1
- package/dist/generated/assets/cldr/pl.json +797 -1
- package/dist/generated/assets/cldr/pt.json +763 -1
- package/dist/generated/assets/cldr/pt_PT.json +763 -1
- package/dist/generated/assets/cldr/ro.json +763 -1
- package/dist/generated/assets/cldr/ru.json +763 -1
- package/dist/generated/assets/cldr/ru_UA.json +763 -1
- package/dist/generated/assets/cldr/sk.json +797 -1
- package/dist/generated/assets/cldr/sl.json +797 -1
- package/dist/generated/assets/cldr/sr.json +763 -1
- package/dist/generated/assets/cldr/sr_Latn.json +763 -1
- package/dist/generated/assets/cldr/sv.json +764 -1
- package/dist/generated/assets/cldr/th.json +831 -1
- package/dist/generated/assets/cldr/tr.json +831 -1
- package/dist/generated/assets/cldr/uk.json +763 -1
- package/dist/generated/assets/cldr/vi.json +763 -1
- package/dist/generated/assets/cldr/zh_CN.json +799 -2
- package/dist/generated/assets/cldr/zh_HK.json +799 -2
- package/dist/generated/assets/cldr/zh_SG.json +799 -2
- package/dist/generated/assets/cldr/zh_TW.json +798 -1
- package/dist/getCachedLocaleDataInstance.d.ts +4 -0
- package/dist/getCachedLocaleDataInstance.js +6 -9
- package/dist/getCachedLocaleDataInstance.js.map +1 -0
- package/dist/locale/getLocaleData.d.ts +11 -0
- package/dist/locale/getLocaleData.js +12 -16
- package/dist/locale/getLocaleData.js.map +1 -0
- package/dist/sap/base/Log.js +28 -29
- package/dist/sap/base/assert.js +5 -6
- package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
- package/dist/sap/base/util/LoaderExtensions.js +9 -12
- package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
- package/dist/sap/ui/core/Configuration.d.ts +17 -0
- package/dist/sap/ui/core/Configuration.js +20 -0
- package/dist/sap/ui/core/Configuration.js.map +1 -0
- package/dist/sap/ui/core/Core.d.ts +26 -0
- package/dist/sap/ui/core/Core.js +7 -34
- package/dist/sap/ui/core/Core.js.map +1 -0
- package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
- package/dist/sap/ui/core/FormatSettings.js +13 -0
- package/dist/sap/ui/core/FormatSettings.js.map +1 -0
- package/dist/sap/ui/core/Locale.js +3 -0
- package/dist/sap/ui/core/LocaleData.js +78 -3
- package/dist/sap/ui/core/date/Buddhist.js +0 -6
- package/dist/sap/ui/core/date/CalendarUtils.js +36 -0
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +7 -0
- package/dist/sap/ui/core/date/Islamic.js +3 -3
- package/dist/sap/ui/core/date/Japanese.js +4 -4
- package/dist/sap/ui/core/date/UniversalDate.js +73 -22
- package/dist/sap/ui/core/format/DateFormat.js +157 -57
- package/dist/sap/ui/core/format/TimezoneUtil.js +12 -1
- package/package-scripts.js +5 -2
- package/package.json +6 -5
- package/src/{Assets-static.js → Assets-static.ts} +0 -0
- package/src/{Assets.js → Assets.ts} +0 -0
- package/src/DateFormat.ts +8 -0
- package/src/LocaleData.ts +8 -0
- package/src/dates/{CalendarDate.js → CalendarDate.ts} +36 -33
- package/src/dates/{ExtremeDates.js → ExtremeDates.ts} +6 -5
- package/src/dates/UniversalDate.ts +51 -0
- package/src/dates/{calculateWeekNumber.js → calculateWeekNumber.ts} +5 -3
- package/src/dates/{convertMonthNumbersToMonthNames.js → convertMonthNumbersToMonthNames.ts} +5 -4
- package/src/dates/{getDaysInMonth.js → getDaysInMonth.ts} +1 -1
- package/src/dates/{getRoundedTimestamp.js → getRoundedTimestamp.ts} +3 -3
- package/src/dates/getTodayUTCTimestamp.ts +10 -0
- package/src/dates/{modifyDateBy.js → modifyDateBy.ts} +1 -1
- package/src/dates/{transformDateToSecondaryType.js → transformDateToSecondaryType.ts} +2 -1
- package/src/features/calendar/Buddhist.ts +1 -0
- package/src/features/calendar/Gregorian.ts +1 -0
- package/src/features/calendar/Islamic.ts +1 -0
- package/src/features/calendar/Japanese.ts +1 -0
- package/src/features/calendar/Persian.ts +1 -0
- package/src/getCachedLocaleDataInstance.ts +15 -0
- package/src/locale/{getLocaleData.js → getLocaleData.ts} +8 -7
- package/src/sap/base/util/{LoaderExtensions.js → LoaderExtensions.ts} +1 -1
- package/src/sap/ui/core/{Core.js → Configuration.ts} +4 -22
- package/src/sap/ui/core/Core.ts +15 -0
- package/src/sap/ui/core/FormatSettings.ts +15 -0
- package/tsconfig.json +13 -0
- package/used-modules.txt +3 -1
- package/src/DateFormat.js +0 -3
- package/src/LocaleData.js +0 -3
- package/src/dates/getTodayUTCTimestamp.js +0 -9
- package/src/getCachedLocaleDataInstance.js +0 -13
@@ -152,11 +152,11 @@ Japanese.prototype.setUTCEra = function (iEra, iYear, iMonth, iDay) {
|
|
152
152
|
}
|
153
153
|
return this._setUTCJapanese(oJapanese);
|
154
154
|
};
|
155
|
-
Japanese.prototype.getWeek = function () {
|
156
|
-
return UniversalDate.getWeekByDate(this.sCalendarType, this.oDate.getFullYear(), this.getMonth(), this.getDate());
|
155
|
+
Japanese.prototype.getWeek = function (oLocale, vCalendarWeekNumbering) {
|
156
|
+
return UniversalDate.getWeekByDate(this.sCalendarType, this.oDate.getFullYear(), this.getMonth(), this.getDate(), oLocale, vCalendarWeekNumbering);
|
157
157
|
};
|
158
|
-
Japanese.prototype.getUTCWeek = function () {
|
159
|
-
return UniversalDate.getWeekByDate(this.sCalendarType, this.oDate.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate());
|
158
|
+
Japanese.prototype.getUTCWeek = function (oLocale, vCalendarWeekNumbering) {
|
159
|
+
return UniversalDate.getWeekByDate(this.sCalendarType, this.oDate.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate(), oLocale, vCalendarWeekNumbering);
|
160
160
|
};
|
161
161
|
_Calendars.set(CalendarType.Japanese, Japanese);
|
162
162
|
export default Japanese;
|
@@ -1,7 +1,10 @@
|
|
1
|
-
import Core from '../Core.js';
|
2
1
|
import BaseObject from '../../base/Object.js';
|
2
|
+
import Configuration from '../Configuration.js';
|
3
|
+
import Locale from '../Locale.js';
|
3
4
|
import LocaleData from '../LocaleData.js';
|
4
5
|
import _Calendars from './_Calendars.js';
|
6
|
+
import CalendarUtils from './CalendarUtils.js';
|
7
|
+
import CalendarWeekNumbering from './CalendarWeekNumbering.js';
|
5
8
|
var UniversalDate = BaseObject.extend('sap.ui.core.date.UniversalDate', {
|
6
9
|
constructor: function () {
|
7
10
|
var clDate = UniversalDate.getClass();
|
@@ -46,7 +49,7 @@ UniversalDate.getInstance = function (oDate, sCalendarType) {
|
|
46
49
|
throw new Error('The given date object is invalid');
|
47
50
|
}
|
48
51
|
if (!sCalendarType) {
|
49
|
-
sCalendarType =
|
52
|
+
sCalendarType = Configuration.getCalendarType();
|
50
53
|
}
|
51
54
|
clDate = UniversalDate.getClass(sCalendarType);
|
52
55
|
oInstance = Object.create(clDate.prototype);
|
@@ -56,7 +59,7 @@ UniversalDate.getInstance = function (oDate, sCalendarType) {
|
|
56
59
|
};
|
57
60
|
UniversalDate.getClass = function (sCalendarType) {
|
58
61
|
if (!sCalendarType) {
|
59
|
-
sCalendarType =
|
62
|
+
sCalendarType = Configuration.getCalendarType();
|
60
63
|
}
|
61
64
|
return _Calendars.get(sCalendarType);
|
62
65
|
};
|
@@ -119,18 +122,22 @@ UniversalDate.prototype.getUTCEra = function () {
|
|
119
122
|
};
|
120
123
|
UniversalDate.prototype.setUTCEra = function (iEra) {
|
121
124
|
};
|
122
|
-
UniversalDate.prototype.getWeek = function () {
|
123
|
-
|
125
|
+
UniversalDate.prototype.getWeek = function (oLocale, vCalendarWeekNumbering) {
|
126
|
+
checkWeekConfig(vCalendarWeekNumbering);
|
127
|
+
return UniversalDate.getWeekByDate(this.sCalendarType, this.getFullYear(), this.getMonth(), this.getDate(), oLocale, vCalendarWeekNumbering);
|
124
128
|
};
|
125
|
-
UniversalDate.prototype.setWeek = function (oWeek) {
|
126
|
-
|
129
|
+
UniversalDate.prototype.setWeek = function (oWeek, oLocale, vCalendarWeekNumbering) {
|
130
|
+
checkWeekConfig(vCalendarWeekNumbering);
|
131
|
+
var oDate = UniversalDate.getFirstDateOfWeek(this.sCalendarType, oWeek.year || this.getFullYear(), oWeek.week, oLocale, vCalendarWeekNumbering);
|
127
132
|
this.setFullYear(oDate.year, oDate.month, oDate.day);
|
128
133
|
};
|
129
|
-
UniversalDate.prototype.getUTCWeek = function () {
|
130
|
-
|
134
|
+
UniversalDate.prototype.getUTCWeek = function (oLocale, vCalendarWeekNumbering) {
|
135
|
+
checkWeekConfig(vCalendarWeekNumbering);
|
136
|
+
return UniversalDate.getWeekByDate(this.sCalendarType, this.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate(), oLocale, vCalendarWeekNumbering);
|
131
137
|
};
|
132
|
-
UniversalDate.prototype.setUTCWeek = function (oWeek) {
|
133
|
-
|
138
|
+
UniversalDate.prototype.setUTCWeek = function (oWeek, oLocale, vCalendarWeekNumbering) {
|
139
|
+
checkWeekConfig(vCalendarWeekNumbering);
|
140
|
+
var oDate = UniversalDate.getFirstDateOfWeek(this.sCalendarType, oWeek.year || this.getFullYear(), oWeek.week, oLocale, vCalendarWeekNumbering);
|
134
141
|
this.setUTCFullYear(oDate.year, oDate.month, oDate.day);
|
135
142
|
};
|
136
143
|
UniversalDate.prototype.getQuarter = function () {
|
@@ -164,15 +171,21 @@ UniversalDate.prototype.getTimezoneLong = function () {
|
|
164
171
|
}
|
165
172
|
};
|
166
173
|
var iMillisecondsInWeek = 7 * 24 * 60 * 60 * 1000;
|
167
|
-
UniversalDate.getWeekByDate = function (sCalendarType, iYear, iMonth, iDay) {
|
168
|
-
|
169
|
-
|
174
|
+
UniversalDate.getWeekByDate = function (sCalendarType, iYear, iMonth, iDay, oLocale, vCalendarWeekNumbering) {
|
175
|
+
checkWeekConfig(vCalendarWeekNumbering);
|
176
|
+
oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
|
177
|
+
var clDate = this.getClass(sCalendarType);
|
178
|
+
var oFirstDay = getFirstDayOfFirstWeek(clDate, iYear, oLocale, vCalendarWeekNumbering);
|
179
|
+
var oDate = new clDate(clDate.UTC(iYear, iMonth, iDay));
|
180
|
+
var iWeek, iLastYear, iNextYear, oLastFirstDay, oNextFirstDay;
|
181
|
+
var bSplitWeek = isSplitWeek(vCalendarWeekNumbering, oLocale);
|
182
|
+
if (bSplitWeek) {
|
170
183
|
iWeek = calculateWeeks(oFirstDay, oDate);
|
171
184
|
} else {
|
172
185
|
iLastYear = iYear - 1;
|
173
186
|
iNextYear = iYear + 1;
|
174
|
-
oLastFirstDay = getFirstDayOfFirstWeek(clDate, iLastYear);
|
175
|
-
oNextFirstDay = getFirstDayOfFirstWeek(clDate, iNextYear);
|
187
|
+
oLastFirstDay = getFirstDayOfFirstWeek(clDate, iLastYear, oLocale, vCalendarWeekNumbering);
|
188
|
+
oNextFirstDay = getFirstDayOfFirstWeek(clDate, iNextYear, oLocale, vCalendarWeekNumbering);
|
176
189
|
if (oDate >= oNextFirstDay) {
|
177
190
|
iYear = iNextYear;
|
178
191
|
iWeek = 0;
|
@@ -188,9 +201,14 @@ UniversalDate.getWeekByDate = function (sCalendarType, iYear, iMonth, iDay) {
|
|
188
201
|
week: iWeek
|
189
202
|
};
|
190
203
|
};
|
191
|
-
UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek) {
|
192
|
-
|
193
|
-
|
204
|
+
UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek, oLocale, vCalendarWeekNumbering) {
|
205
|
+
checkWeekConfig(vCalendarWeekNumbering);
|
206
|
+
oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
|
207
|
+
var clDate = this.getClass(sCalendarType);
|
208
|
+
var oFirstDay = getFirstDayOfFirstWeek(clDate, iYear, oLocale, vCalendarWeekNumbering);
|
209
|
+
var oDate = new clDate(oFirstDay.valueOf() + iWeek * iMillisecondsInWeek);
|
210
|
+
var bSplitWeek = isSplitWeek(vCalendarWeekNumbering, oLocale);
|
211
|
+
if (bSplitWeek && iWeek === 0 && oFirstDay.getUTCFullYear() < iYear) {
|
194
212
|
return {
|
195
213
|
year: iYear,
|
196
214
|
month: 0,
|
@@ -203,8 +221,41 @@ UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek) {
|
|
203
221
|
day: oDate.getUTCDate()
|
204
222
|
};
|
205
223
|
};
|
206
|
-
function
|
207
|
-
|
224
|
+
function isSplitWeek(vCalendarWeekNumbering, oLocale) {
|
225
|
+
oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
|
226
|
+
var oLocaleData = LocaleData.getInstance(oLocale);
|
227
|
+
return (!isCalendarWeekConfigurationDefined(vCalendarWeekNumbering) || vCalendarWeekNumbering === CalendarWeekNumbering.Default) && oLocaleData.firstDayStartsFirstWeek();
|
228
|
+
}
|
229
|
+
function checkWeekConfig(vCalendarWeekNumbering) {
|
230
|
+
if (typeof vCalendarWeekNumbering === 'object') {
|
231
|
+
if (!isCalendarWeekConfigurationDefined(vCalendarWeekNumbering)) {
|
232
|
+
throw new TypeError('Week config requires firstDayOfWeek and minimalDaysInFirstWeek to be set');
|
233
|
+
}
|
234
|
+
} else if (vCalendarWeekNumbering && !Object.values(CalendarWeekNumbering).includes(vCalendarWeekNumbering)) {
|
235
|
+
throw new TypeError('Illegal format option calendarWeekNumbering: \'' + vCalendarWeekNumbering + '\'');
|
236
|
+
}
|
237
|
+
}
|
238
|
+
function isCalendarWeekConfigurationDefined(vCalendarWeekNumbering) {
|
239
|
+
if (typeof vCalendarWeekNumbering === 'object') {
|
240
|
+
return typeof vCalendarWeekNumbering.firstDayOfWeek === 'number' && typeof vCalendarWeekNumbering.minimalDaysInFirstWeek === 'number';
|
241
|
+
} else if (vCalendarWeekNumbering) {
|
242
|
+
return true;
|
243
|
+
}
|
244
|
+
return false;
|
245
|
+
}
|
246
|
+
function resolveCalendarWeekConfiguration(vCalendarWeekNumbering, oLocale) {
|
247
|
+
if (typeof vCalendarWeekNumbering === 'object' && typeof vCalendarWeekNumbering.firstDayOfWeek === 'number' && typeof vCalendarWeekNumbering.minimalDaysInFirstWeek === 'number') {
|
248
|
+
return vCalendarWeekNumbering;
|
249
|
+
}
|
250
|
+
return CalendarUtils.getWeekConfigurationValues(vCalendarWeekNumbering, oLocale);
|
251
|
+
}
|
252
|
+
function getFirstDayOfFirstWeek(clDate, iYear, oLocale, vCalendarWeekNumbering) {
|
253
|
+
oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
|
254
|
+
var oWeekConfig = resolveCalendarWeekConfiguration(vCalendarWeekNumbering, oLocale);
|
255
|
+
var iMinDays = oWeekConfig.minimalDaysInFirstWeek;
|
256
|
+
var iFirstDayOfWeek = oWeekConfig.firstDayOfWeek;
|
257
|
+
var oFirstDay = new clDate(clDate.UTC(iYear, 0, 1));
|
258
|
+
var iDayCount = 7;
|
208
259
|
if (isNaN(oFirstDay.getTime())) {
|
209
260
|
throw new Error('Could not determine the first day of the week, because the date ' + 'object is invalid');
|
210
261
|
}
|
@@ -247,7 +298,7 @@ UniversalDate.getEraStartDate = function (sCalendarType, iEra) {
|
|
247
298
|
}
|
248
299
|
};
|
249
300
|
function getEras(sCalendarType) {
|
250
|
-
var oLocale =
|
301
|
+
var oLocale = Configuration.getFormatSettings().getFormatLocale(), oLocaleData = LocaleData.getInstance(oLocale), aEras = mEras[sCalendarType];
|
251
302
|
if (!aEras) {
|
252
303
|
var aEras = oLocaleData.getEraDates(sCalendarType);
|
253
304
|
if (!aEras[0]) {
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import Core from '../Core.js';
|
2
1
|
import CalendarType from '../CalendarType.js';
|
3
2
|
import Locale from '../Locale.js';
|
4
3
|
import LocaleData from '../LocaleData.js';
|
5
4
|
import UniversalDate from '../date/UniversalDate.js';
|
5
|
+
import CalendarUtils from '../date/CalendarUtils.js';
|
6
|
+
import CalendarWeekNumbering from '../date/CalendarWeekNumbering.js';
|
6
7
|
import TimezoneUtil from './TimezoneUtil.js';
|
7
8
|
import deepEqual from '../../../base/util/deepEqual.js';
|
8
9
|
import formatMessage from '../../../base/strings/formatMessage.js';
|
9
10
|
import Log from '../../../base/Log.js';
|
10
11
|
import extend from '../../../base/util/extend.js';
|
12
|
+
import Configuration from '../Configuration.js';
|
11
13
|
var DateFormat = function () {
|
12
14
|
throw new Error();
|
13
15
|
};
|
@@ -263,7 +265,7 @@ DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo) {
|
|
263
265
|
oFormatOptions = undefined;
|
264
266
|
}
|
265
267
|
if (!oLocale) {
|
266
|
-
oLocale =
|
268
|
+
oLocale = Configuration.getFormatSettings().getFormatLocale();
|
267
269
|
}
|
268
270
|
oFormat.oLocale = oLocale;
|
269
271
|
oFormat.oLocaleData = LocaleData.getInstance(oLocale);
|
@@ -279,7 +281,13 @@ DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo) {
|
|
279
281
|
}
|
280
282
|
oFormat.type = oInfo.type;
|
281
283
|
if (!oFormat.oFormatOptions.calendarType) {
|
282
|
-
oFormat.oFormatOptions.calendarType =
|
284
|
+
oFormat.oFormatOptions.calendarType = Configuration.getCalendarType();
|
285
|
+
}
|
286
|
+
if (oFormat.oFormatOptions.firstDayOfWeek === undefined && oFormat.oFormatOptions.minimalDaysInFirstWeek !== undefined || oFormat.oFormatOptions.firstDayOfWeek !== undefined && oFormat.oFormatOptions.minimalDaysInFirstWeek === undefined) {
|
287
|
+
throw new TypeError('Format options firstDayOfWeek and minimalDaysInFirstWeek need both to be set, but only one was provided.');
|
288
|
+
}
|
289
|
+
if (oFormat.oFormatOptions.calendarWeekNumbering && !Object.values(CalendarWeekNumbering).includes(oFormat.oFormatOptions.calendarWeekNumbering)) {
|
290
|
+
throw new TypeError('Illegal format option calendarWeekNumbering: \'' + oFormat.oFormatOptions.calendarWeekNumbering + '\'');
|
283
291
|
}
|
284
292
|
if (!oFormat.oFormatOptions.pattern) {
|
285
293
|
if (oFormat.oFormatOptions.format) {
|
@@ -361,7 +369,15 @@ DateFormat.prototype.init = function () {
|
|
361
369
|
this.aErasNarrow = this.oLocaleData.getEras('narrow', sCalendarType);
|
362
370
|
this.aErasAbbrev = this.oLocaleData.getEras('abbreviated', sCalendarType);
|
363
371
|
this.aErasWide = this.oLocaleData.getEras('wide', sCalendarType);
|
364
|
-
this.
|
372
|
+
this.aDayPeriodsAbbrev = this.oLocaleData.getDayPeriods('abbreviated', sCalendarType);
|
373
|
+
this.aDayPeriodsNarrow = this.oLocaleData.getDayPeriods('narrow', sCalendarType);
|
374
|
+
this.aDayPeriodsWide = this.oLocaleData.getDayPeriods('wide', sCalendarType);
|
375
|
+
this.oFlexibleDayPeriodsAbbrev = this.oLocaleData.getFlexibleDayPeriods('abbreviated', sCalendarType);
|
376
|
+
this.oFlexibleDayPeriodsNarrow = this.oLocaleData.getFlexibleDayPeriods('narrow', sCalendarType);
|
377
|
+
this.oFlexibleDayPeriodsWide = this.oLocaleData.getFlexibleDayPeriods('wide', sCalendarType);
|
378
|
+
this.oFlexibleDayPeriodsAbbrevSt = this.oLocaleData.getFlexibleDayPeriodsStandAlone('abbreviated', sCalendarType);
|
379
|
+
this.oFlexibleDayPeriodsNarrowSt = this.oLocaleData.getFlexibleDayPeriodsStandAlone('narrow', sCalendarType);
|
380
|
+
this.oFlexibleDayPeriodsWideSt = this.oLocaleData.getFlexibleDayPeriodsStandAlone('wide', sCalendarType);
|
365
381
|
this.aFormatArray = this.parseCldrDatePattern(this.oFormatOptions.pattern);
|
366
382
|
this.sAllowedCharacters = this.getAllowedCharacters(this.aFormatArray);
|
367
383
|
};
|
@@ -601,7 +617,7 @@ DateFormat.prototype.oSymbols = {
|
|
601
617
|
'Y': {
|
602
618
|
name: 'weekYear',
|
603
619
|
format: function (oField, oDate, bUTC, oFormat) {
|
604
|
-
var oWeek = oDate.getUTCWeek();
|
620
|
+
var oWeek = oDate.getUTCWeek(oFormat.oLocale, getCalendarWeekParameter(oFormat.oFormatOptions));
|
605
621
|
var iWeekYear = oWeek.year;
|
606
622
|
var sWeekYear = String(iWeekYear);
|
607
623
|
var sCalendarType = oFormat.oFormatOptions.calendarType;
|
@@ -752,7 +768,7 @@ DateFormat.prototype.oSymbols = {
|
|
752
768
|
'w': {
|
753
769
|
name: 'weekInYear',
|
754
770
|
format: function (oField, oDate, bUTC, oFormat) {
|
755
|
-
var oWeek = oDate.getUTCWeek();
|
771
|
+
var oWeek = oDate.getUTCWeek(oFormat.oLocale, getCalendarWeekParameter(oFormat.oFormatOptions));
|
756
772
|
var iWeek = oWeek.week;
|
757
773
|
var sWeek = String(iWeek + 1);
|
758
774
|
if (oField.digits < 3) {
|
@@ -1034,35 +1050,89 @@ DateFormat.prototype.oSymbols = {
|
|
1034
1050
|
name: 'amPmMarker',
|
1035
1051
|
format: function (oField, oDate, bUTC, oFormat) {
|
1036
1052
|
var iDayPeriod = oDate.getUTCDayPeriod();
|
1037
|
-
|
1053
|
+
if (oField.digits <= 3) {
|
1054
|
+
return oFormat.aDayPeriodsAbbrev[iDayPeriod];
|
1055
|
+
} else if (oField.digits === 4) {
|
1056
|
+
return oFormat.aDayPeriodsWide[iDayPeriod];
|
1057
|
+
} else {
|
1058
|
+
return oFormat.aDayPeriodsNarrow[iDayPeriod];
|
1059
|
+
}
|
1060
|
+
},
|
1061
|
+
parse: function (sValue, oPart, oFormat, oConfig, sTimezone) {
|
1062
|
+
var rAMPM, bAMPMAlternativeCase, oEntry, i, aMatch, normalize, aVariants, aDayPeriodsVariants = [
|
1063
|
+
oFormat.aDayPeriodsWide,
|
1064
|
+
oFormat.aDayPeriodsAbbrev,
|
1065
|
+
oFormat.aDayPeriodsNarrow
|
1066
|
+
];
|
1067
|
+
rAMPM = /[aApP](?:\.)?[\x20\xA0]?[mM](?:\.)?/;
|
1068
|
+
aMatch = sValue.match(rAMPM);
|
1069
|
+
bAMPMAlternativeCase = aMatch && aMatch.index === 0;
|
1070
|
+
function normalize(sValue) {
|
1071
|
+
return sValue.replace(/[\x20\xA0]/g, '').replace(/\./g, '');
|
1072
|
+
}
|
1073
|
+
if (bAMPMAlternativeCase) {
|
1074
|
+
sValue = normalize(sValue);
|
1075
|
+
}
|
1076
|
+
for (i = 0; i < aDayPeriodsVariants.length; i += 1) {
|
1077
|
+
aVariants = aDayPeriodsVariants[i];
|
1078
|
+
if (bAMPMAlternativeCase) {
|
1079
|
+
aVariants = aVariants.map(normalize);
|
1080
|
+
}
|
1081
|
+
oEntry = oParseHelper.findEntry(sValue, aVariants, oFormat.oLocaleData.sCLDRLocaleId);
|
1082
|
+
if (oEntry.index !== -1) {
|
1083
|
+
return {
|
1084
|
+
pm: oEntry.index === 1,
|
1085
|
+
length: bAMPMAlternativeCase ? aMatch[0].length : oEntry.length
|
1086
|
+
};
|
1087
|
+
}
|
1088
|
+
}
|
1089
|
+
return { valid: false };
|
1090
|
+
}
|
1091
|
+
},
|
1092
|
+
'B': {
|
1093
|
+
name: 'flexibleDayPeriod',
|
1094
|
+
format: function (oField, oDate, bUTC, oFormat) {
|
1095
|
+
var bContainsHour = oFormat.aFormatArray.some(function (oFormatElement) {
|
1096
|
+
return 'hHKk'.includes(oFormatElement.symbol);
|
1097
|
+
}), sFlexibleDayPeriod = oFormat.oLocaleData.getFlexibleDayPeriodOfTime(oDate.getUTCHours(), oDate.getUTCMinutes());
|
1098
|
+
if (bContainsHour) {
|
1099
|
+
if (oField.digits <= 3) {
|
1100
|
+
return oFormat.oFlexibleDayPeriodsAbbrev[sFlexibleDayPeriod];
|
1101
|
+
}
|
1102
|
+
if (oField.digits === 4) {
|
1103
|
+
return oFormat.oFlexibleDayPeriodsWide[sFlexibleDayPeriod];
|
1104
|
+
}
|
1105
|
+
return oFormat.oFlexibleDayPeriodsNarrow[sFlexibleDayPeriod];
|
1106
|
+
}
|
1107
|
+
if (oField.digits <= 3) {
|
1108
|
+
return oFormat.oFlexibleDayPeriodsAbbrevSt[sFlexibleDayPeriod];
|
1109
|
+
}
|
1110
|
+
if (oField.digits === 4) {
|
1111
|
+
return oFormat.oFlexibleDayPeriodsWideSt[sFlexibleDayPeriod];
|
1112
|
+
}
|
1113
|
+
return oFormat.oFlexibleDayPeriodsNarrowSt[sFlexibleDayPeriod];
|
1038
1114
|
},
|
1039
1115
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1040
|
-
var
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
} else if (sValue.indexOf(sPM) === 0) {
|
1059
|
-
bPM = true;
|
1060
|
-
iLength = bVariant ? aMatch[0].length : sPM.length;
|
1116
|
+
var i, oFound, oVariant, bContainsHour = oFormat.aFormatArray.some(function (oFormatElement) {
|
1117
|
+
return 'hHKk'.includes(oFormatElement.symbol);
|
1118
|
+
}), aFlexibleDayPeriodVariants = [
|
1119
|
+
oFormat.oFlexibleDayPeriodsWide,
|
1120
|
+
oFormat.oFlexibleDayPeriodsAbbrev,
|
1121
|
+
oFormat.oFlexibleDayPeriodsNarrow
|
1122
|
+
];
|
1123
|
+
if (bContainsHour) {
|
1124
|
+
for (i = 0; i < aFlexibleDayPeriodVariants.length; i++) {
|
1125
|
+
oVariant = aFlexibleDayPeriodVariants[i];
|
1126
|
+
oFound = oParseHelper.findEntry(sValue, Object.values(oVariant), oFormat.oLocaleData.sCLDRLocaleId);
|
1127
|
+
if (oFound.index !== -1) {
|
1128
|
+
return {
|
1129
|
+
flexDayPeriod: Object.keys(oVariant)[oFound.index],
|
1130
|
+
length: oFound.length
|
1131
|
+
};
|
1132
|
+
}
|
1133
|
+
}
|
1061
1134
|
}
|
1062
|
-
return {
|
1063
|
-
pm: bPM,
|
1064
|
-
length: iLength
|
1065
|
-
};
|
1135
|
+
return { valid: false };
|
1066
1136
|
}
|
1067
1137
|
},
|
1068
1138
|
'H': {
|
@@ -1338,7 +1408,7 @@ DateFormat.prototype.oSymbols = {
|
|
1338
1408
|
name: 'timezoneID',
|
1339
1409
|
format: function (oField, oDate, bUTC, oFormat, sTimezone) {
|
1340
1410
|
if (!bUTC && oField.digits === 2) {
|
1341
|
-
return sTimezone;
|
1411
|
+
return oFormat.oLocaleData.getTimezoneTranslations()[sTimezone] || sTimezone;
|
1342
1412
|
}
|
1343
1413
|
return '';
|
1344
1414
|
},
|
@@ -1348,18 +1418,27 @@ DateFormat.prototype.oSymbols = {
|
|
1348
1418
|
length: 0
|
1349
1419
|
};
|
1350
1420
|
if (oPart.digits === 2) {
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1421
|
+
var mTimezoneTranslations = oFormat.oLocaleData.getTimezoneTranslations();
|
1422
|
+
if (sValue === mTimezoneTranslations[sTimezone]) {
|
1423
|
+
return {
|
1424
|
+
timezone: sTimezone,
|
1425
|
+
length: sValue.length
|
1426
|
+
};
|
1355
1427
|
}
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1428
|
+
var aTimezoneTranslations = Object.values(mTimezoneTranslations);
|
1429
|
+
var oTimezoneResult = oParseHelper.findEntry(sValue, aTimezoneTranslations, oFormat.oLocaleData.sCLDRLocaleId);
|
1430
|
+
if (oTimezoneResult.index !== -1) {
|
1431
|
+
return {
|
1432
|
+
timezone: Object.keys(mTimezoneTranslations)[oTimezoneResult.index],
|
1433
|
+
length: oTimezoneResult.length
|
1434
|
+
};
|
1435
|
+
}
|
1436
|
+
var sCurrentValue = '';
|
1437
|
+
for (var i = 0; i < sValue.length; i++) {
|
1438
|
+
sCurrentValue += sValue[i];
|
1439
|
+
if (TimezoneUtil.isValidTimezone(sCurrentValue)) {
|
1440
|
+
oTimezoneParsed.timezone = sCurrentValue;
|
1441
|
+
oTimezoneParsed.length = sCurrentValue.length;
|
1363
1442
|
}
|
1364
1443
|
}
|
1365
1444
|
}
|
@@ -1383,7 +1462,7 @@ DateFormat.prototype._format = function (oJSDate, bUTC, sTimezone) {
|
|
1383
1462
|
aBuffer.push(this.oSymbols[sSymbol].format(oPart, oDate, bUTC, this, sTimezone));
|
1384
1463
|
}
|
1385
1464
|
sResult = aBuffer.join('');
|
1386
|
-
if (
|
1465
|
+
if (Configuration.getOriginInfo()) {
|
1387
1466
|
sResult = new String(sResult);
|
1388
1467
|
sResult.originInfo = {
|
1389
1468
|
source: 'Common Locale Data Repository',
|
@@ -1409,7 +1488,7 @@ DateFormat.prototype.format = function (vJSDate, bUTC) {
|
|
1409
1488
|
if (bUTC === undefined) {
|
1410
1489
|
bUTC = this.oFormatOptions.UTC;
|
1411
1490
|
}
|
1412
|
-
sTimezone = sTimezone ||
|
1491
|
+
sTimezone = sTimezone || Configuration.getTimezone();
|
1413
1492
|
if (Array.isArray(vJSDate)) {
|
1414
1493
|
if (!this.oFormatOptions.interval) {
|
1415
1494
|
Log.error('Non-interval DateFormat can\'t format more than one date instance.');
|
@@ -1441,7 +1520,7 @@ DateFormat.prototype.format = function (vJSDate, bUTC) {
|
|
1441
1520
|
} else {
|
1442
1521
|
if (!isValidDateObject(vJSDate)) {
|
1443
1522
|
if (this.type === mDateFormatTypes.DATETIME_WITH_TIMEZONE && this.oFormatOptions.pattern.includes('VV')) {
|
1444
|
-
return sTimezone;
|
1523
|
+
return this.oLocaleData.getTimezoneTranslations()[sTimezone] || sTimezone;
|
1445
1524
|
}
|
1446
1525
|
Log.error('The given date instance isn\'t valid.');
|
1447
1526
|
return '';
|
@@ -1519,7 +1598,7 @@ DateFormat.prototype._getGreatestDiffField = function (aDates) {
|
|
1519
1598
|
return null;
|
1520
1599
|
};
|
1521
1600
|
DateFormat.prototype._parse = function (sValue, aFormatArray, bUTC, bStrict, sTimezone) {
|
1522
|
-
var iIndex = 0, oPart, sSubValue, oResult;
|
1601
|
+
var iIndex = 0, sFlexibleDayPeriod, oPart, bPM, sSubValue, oResult;
|
1523
1602
|
var oDateValue = {
|
1524
1603
|
valid: true,
|
1525
1604
|
lastTimezonePatternSymbol: ''
|
@@ -1544,7 +1623,12 @@ DateFormat.prototype._parse = function (sValue, aFormatArray, bUTC, bStrict, sTi
|
|
1544
1623
|
iIndex += oResult.length || 0;
|
1545
1624
|
}
|
1546
1625
|
oDateValue.index = iIndex;
|
1547
|
-
|
1626
|
+
bPM = oDateValue.pm;
|
1627
|
+
if (oDateValue.flexDayPeriod && oDateValue.hour * 60 + (oDateValue.minute || 0) < 720) {
|
1628
|
+
sFlexibleDayPeriod = this.oLocaleData.getFlexibleDayPeriodOfTime(oDateValue.hour + 12, oDateValue.minute || 0);
|
1629
|
+
bPM = oDateValue.flexDayPeriod === sFlexibleDayPeriod;
|
1630
|
+
}
|
1631
|
+
if (bPM) {
|
1548
1632
|
oDateValue.hour += 12;
|
1549
1633
|
}
|
1550
1634
|
if (oDateValue.dayNumberOfWeek === undefined && oDateValue.dayOfWeek !== undefined) {
|
@@ -1601,13 +1685,24 @@ DateFormat.prototype._parseInterval = function (sValue, sCalendarType, bUTC, bSt
|
|
1601
1685
|
}.bind(this));
|
1602
1686
|
return aDateValues;
|
1603
1687
|
};
|
1688
|
+
function getCalendarWeekParameter(oFormatOptions) {
|
1689
|
+
if (oFormatOptions.calendarWeekNumbering) {
|
1690
|
+
return oFormatOptions.calendarWeekNumbering;
|
1691
|
+
} else if (oFormatOptions.firstDayOfWeek !== undefined && oFormatOptions.minimalDaysInFirstWeek !== undefined) {
|
1692
|
+
return {
|
1693
|
+
firstDayOfWeek: oFormatOptions.firstDayOfWeek,
|
1694
|
+
minimalDaysInFirstWeek: oFormatOptions.minimalDaysInFirstWeek
|
1695
|
+
};
|
1696
|
+
}
|
1697
|
+
return undefined;
|
1698
|
+
}
|
1604
1699
|
var convertToTimezone = function (oJSDate, sTimezone, bUTC) {
|
1605
1700
|
if (!bUTC && isValidDateObject(oJSDate)) {
|
1606
1701
|
return TimezoneUtil.convertToTimezone(oJSDate, sTimezone);
|
1607
1702
|
}
|
1608
1703
|
return oJSDate;
|
1609
1704
|
};
|
1610
|
-
var fnCreateDate = function (oDateValue, sCalendarType, bUTC, bStrict, sTimezone) {
|
1705
|
+
var fnCreateDate = function (oDateValue, sCalendarType, bUTC, bStrict, sTimezone, oFormatOptions, oLocale) {
|
1611
1706
|
if (!oDateValue.valid) {
|
1612
1707
|
return null;
|
1613
1708
|
}
|
@@ -1628,7 +1723,7 @@ var fnCreateDate = function (oDateValue, sCalendarType, bUTC, bStrict, sTimezone
|
|
1628
1723
|
oDate.setUTCWeek({
|
1629
1724
|
year: oDateValue.weekYear || oDateValue.year,
|
1630
1725
|
week: oDateValue.week
|
1631
|
-
});
|
1726
|
+
}, oLocale, getCalendarWeekParameter(oFormatOptions));
|
1632
1727
|
if (oDateValue.dayNumberOfWeek !== undefined) {
|
1633
1728
|
oDate.setUTCDate(oDate.getUTCDate() + oDateValue.dayNumberOfWeek - 1);
|
1634
1729
|
}
|
@@ -1643,7 +1738,7 @@ var fnCreateDate = function (oDateValue, sCalendarType, bUTC, bStrict, sTimezone
|
|
1643
1738
|
}
|
1644
1739
|
}
|
1645
1740
|
if (oDateValue.tzDiff) {
|
1646
|
-
oDate.setUTCSeconds((
|
1741
|
+
oDate.setUTCSeconds(oDate.getUTCSeconds() + oDateValue.tzDiff);
|
1647
1742
|
}
|
1648
1743
|
return oDate;
|
1649
1744
|
};
|
@@ -1694,7 +1789,7 @@ DateFormat.prototype.parse = function (sValue, bUTC, bStrict) {
|
|
1694
1789
|
sValue = sValue == null ? '' : String(sValue).trim();
|
1695
1790
|
var oDateValue;
|
1696
1791
|
var sCalendarType = this.oFormatOptions.calendarType;
|
1697
|
-
sTimezone = sTimezone ||
|
1792
|
+
sTimezone = sTimezone || Configuration.getTimezone();
|
1698
1793
|
if (bStrict === undefined) {
|
1699
1794
|
bStrict = this.oFormatOptions.strictParsing;
|
1700
1795
|
}
|
@@ -1710,7 +1805,7 @@ DateFormat.prototype.parse = function (sValue, bUTC, bStrict) {
|
|
1710
1805
|
if (oDateValue.index === 0 || oDateValue.index < sValue.length) {
|
1711
1806
|
oDateValue.valid = false;
|
1712
1807
|
}
|
1713
|
-
oJSDate = fnCreateDate(oDateValue, sCalendarType, bUTC, bStrict, sTimezone);
|
1808
|
+
oJSDate = fnCreateDate(oDateValue, sCalendarType, bUTC, bStrict, sTimezone, this.oFormatOptions, this.oLocale);
|
1714
1809
|
if (oJSDate) {
|
1715
1810
|
if (this.type === mDateFormatTypes.DATETIME_WITH_TIMEZONE) {
|
1716
1811
|
var bShowTimezone = this.oFormatOptions.showTimezone === undefined || this.oFormatOptions.showTimezone;
|
@@ -1738,8 +1833,8 @@ DateFormat.prototype.parse = function (sValue, bUTC, bStrict) {
|
|
1738
1833
|
if (aDateValues && aDateValues.length == 2) {
|
1739
1834
|
var oDateValue1 = mergeWithoutOverwrite(aDateValues[0], aDateValues[1]);
|
1740
1835
|
var oDateValue2 = mergeWithoutOverwrite(aDateValues[1], aDateValues[0]);
|
1741
|
-
oJSDate1 = fnCreateDate(oDateValue1, sCalendarType, bUTC, bStrict, sTimezone);
|
1742
|
-
oJSDate2 = fnCreateDate(oDateValue2, sCalendarType, bUTC, bStrict, sTimezone);
|
1836
|
+
oJSDate1 = fnCreateDate(oDateValue1, sCalendarType, bUTC, bStrict, sTimezone, this.oFormatOptions, this.oLocale);
|
1837
|
+
oJSDate2 = fnCreateDate(oDateValue2, sCalendarType, bUTC, bStrict, sTimezone, this.oFormatOptions, this.oLocale);
|
1743
1838
|
if (oJSDate1 && oJSDate2) {
|
1744
1839
|
if (this.oFormatOptions.singleIntervalValue && oJSDate1.getTime() === oJSDate2.getTime()) {
|
1745
1840
|
return [
|
@@ -2067,7 +2162,12 @@ var mRelativeDiffs = {
|
|
2067
2162
|
}
|
2068
2163
|
};
|
2069
2164
|
DateFormat.prototype._adaptDayOfWeek = function (iDayOfWeek) {
|
2070
|
-
var
|
2165
|
+
var vCalendarWeekParameter = getCalendarWeekParameter(this.oFormatOptions), iFirstDayOfWeek;
|
2166
|
+
if (typeof vCalendarWeekParameter === 'object') {
|
2167
|
+
iFirstDayOfWeek = vCalendarWeekParameter.firstDayOfWeek;
|
2168
|
+
} else {
|
2169
|
+
iFirstDayOfWeek = CalendarUtils.getWeekConfigurationValues(vCalendarWeekParameter, this.oLocale).firstDayOfWeek;
|
2170
|
+
}
|
2071
2171
|
var iDayNumberOfWeek = iDayOfWeek - (iFirstDayOfWeek - 1);
|
2072
2172
|
if (iDayNumberOfWeek <= 0) {
|
2073
2173
|
iDayNumberOfWeek += 7;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
var TimezoneUtil = {};
|
2
2
|
var sLocalTimezone = "";
|
3
|
+
var aSupportedTimezoneIDs;
|
3
4
|
var oIntlDateTimeFormatCache = {
|
4
5
|
_oCache: new Map(),
|
5
6
|
_iCacheLimit: 10,
|
@@ -33,6 +34,16 @@ TimezoneUtil.isValidTimezone = function (sTimezone) {
|
|
33
34
|
if (!sTimezone) {
|
34
35
|
return false;
|
35
36
|
}
|
37
|
+
if (Intl.supportedValuesOf) {
|
38
|
+
try {
|
39
|
+
aSupportedTimezoneIDs = aSupportedTimezoneIDs || Intl.supportedValuesOf("timeZone");
|
40
|
+
if (aSupportedTimezoneIDs.includes(sTimezone)) {
|
41
|
+
return true;
|
42
|
+
}
|
43
|
+
} catch (oError) {
|
44
|
+
aSupportedTimezoneIDs = [];
|
45
|
+
}
|
46
|
+
}
|
36
47
|
try {
|
37
48
|
oIntlDateTimeFormatCache.get(sTimezone);
|
38
49
|
return true;
|
@@ -63,7 +74,7 @@ TimezoneUtil._getDateFromParts = function (oParts) {
|
|
63
74
|
iUTCYear = iUTCYear * -1 + 1;
|
64
75
|
}
|
65
76
|
oDate.setUTCFullYear(iUTCYear, parseInt(oParts.month) - 1, parseInt(oParts.day));
|
66
|
-
oDate.setUTCHours(parseInt(oParts.hour), parseInt(oParts.minute), parseInt(oParts.second), parseInt(oParts.fractionalSecond));
|
77
|
+
oDate.setUTCHours(parseInt(oParts.hour), parseInt(oParts.minute), parseInt(oParts.second), parseInt(oParts.fractionalSecond || 0));
|
67
78
|
return oDate;
|
68
79
|
};
|
69
80
|
TimezoneUtil.calculateOffset = function (oDate, sTimezoneSource) {
|
package/package-scripts.js
CHANGED
@@ -7,15 +7,17 @@ const scripts = {
|
|
7
7
|
clean: "rimraf dist",
|
8
8
|
lint: "eslint . --config config/.eslintrc.js",
|
9
9
|
build: {
|
10
|
-
"default": "nps lint clean copy.used-modules copy.cldr copy.overlay build.replace-amd build.replace-export-true build.replace-export-false build.amd-to-es6 build.replace-global-core-usage build.esm-abs-to-rel build.jsonImports copy.src",
|
10
|
+
"default": "nps lint clean copy.used-modules copy.cldr copy.overlay build.replace-amd build.replace-export-true build.replace-export-false build.amd-to-es6 build.replace-global-core-usage build.esm-abs-to-rel build.jsonImports build.typescript copy.src",
|
11
11
|
"replace-amd": "replace-in-file sap.ui.define define dist/**/*.js",
|
12
12
|
"replace-export-true": `replace-in-file ", /* bExport= */ true" "" dist/**/*.js`,
|
13
13
|
"replace-export-false": `replace-in-file ", /* bExport= */ false" "" dist/**/*.js`,
|
14
14
|
"amd-to-es6": "amdtoes6 --src=dist --replace --glob=**/*.js",
|
15
15
|
"replace-global-core-usage": `node "${replaceGlobalCore}" dist/`,
|
16
16
|
"esm-abs-to-rel": `node "${esmAbsToRel}" dist/`,
|
17
|
+
typescript: "tsc",
|
17
18
|
jsonImports: "node ./lib/generate-json-imports/cldr.js"
|
18
19
|
},
|
20
|
+
typescript: "tsc",
|
19
21
|
copy: {
|
20
22
|
"used-modules": `node "${copyUsedModules}" ./used-modules.txt dist/`,
|
21
23
|
cldr: `copy-and-watch "../../node_modules/@openui5/sap.ui.core/src/sap/ui/core/cldr/*.json" dist/generated/assets/cldr/`,
|
@@ -23,7 +25,8 @@ const scripts = {
|
|
23
25
|
src: `copy-and-watch "src/**/*.js" dist/`,
|
24
26
|
},
|
25
27
|
watch: {
|
26
|
-
default: 'nps watch.src',
|
28
|
+
default: 'concurrently "nps watch.src" "nps watch.typescript" ',
|
29
|
+
typescript: "tsc --watch",
|
27
30
|
src: `nps "copy.src --watch --skip-initial-copy"`,
|
28
31
|
},
|
29
32
|
start: "nps watch",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-localization",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.10.0",
|
4
4
|
"description": "Localization for UI5 Web Components",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -27,13 +27,14 @@
|
|
27
27
|
"prepublishOnly": "npm run clean && npm run build"
|
28
28
|
},
|
29
29
|
"devDependencies": {
|
30
|
-
"@openui5/sap.ui.core": "1.
|
31
|
-
"@
|
32
|
-
"
|
30
|
+
"@openui5/sap.ui.core": "1.109.0",
|
31
|
+
"@types/openui5": "^1.108.0",
|
32
|
+
"@ui5/webcomponents-tools": "1.10.0",
|
33
|
+
"chromedriver": "108.0.0",
|
33
34
|
"mkdirp": "^1.0.4",
|
34
35
|
"resolve": "^1.20.0"
|
35
36
|
},
|
36
37
|
"dependencies": {
|
37
|
-
"@ui5/webcomponents-base": "1.
|
38
|
+
"@ui5/webcomponents-base": "1.10.0"
|
38
39
|
}
|
39
40
|
}
|
File without changes
|
File without changes
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type DateFormatT from "sap/ui/core/format/DateFormat";
|
2
|
+
// @ts-ignore
|
3
|
+
import DateFormatNative from "./sap/ui/core/format/DateFormat.js";
|
4
|
+
|
5
|
+
const DateFormatWrapped = DateFormatNative as typeof DateFormatT;
|
6
|
+
class DateFormat extends DateFormatWrapped {}
|
7
|
+
|
8
|
+
export default DateFormat;
|