@ui5/webcomponents-localization 0.0.0-c41f1b293 → 0.0.0-c6c04c609
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 +245 -0
- package/README.md +2 -1
- package/dist/dates/modifyDateBy.d.ts +2 -1
- package/dist/dates/modifyDateBy.js +34 -19
- package/dist/dates/modifyDateBy.js.map +1 -1
- package/dist/generated/json-imports/LocaleData.js +74 -74
- package/dist/sap/base/i18n/LanguageTag.js +35 -0
- package/dist/sap/base/i18n/Localization.d.ts +4 -0
- package/dist/sap/base/i18n/Localization.js +12 -0
- package/dist/sap/base/i18n/Localization.js.map +1 -0
- package/dist/sap/base/i18n/date/CalendarType.js +8 -0
- package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +30 -0
- package/dist/sap/base/i18n/date/TimezoneUtils.js +89 -0
- package/dist/sap/ui/base/Metadata.js +20 -9
- package/dist/sap/ui/core/CalendarType.js +2 -8
- package/dist/sap/ui/core/Configuration.d.ts +1 -0
- package/dist/sap/ui/core/Configuration.js +2 -0
- package/dist/sap/ui/core/Configuration.js.map +1 -1
- package/dist/sap/ui/core/Core.d.ts +1 -0
- package/dist/sap/ui/core/Locale.js +28 -125
- package/dist/sap/ui/core/LocaleData.js +36 -18
- package/dist/sap/ui/core/date/CalendarUtils.js +7 -18
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +2 -7
- package/dist/sap/ui/core/date/UniversalDate.js +5 -16
- package/dist/sap/ui/core/format/DateFormat.js +79 -37
- package/dist/sap/ui/core/format/TimezoneUtil.js +2 -89
- package/package.json +5 -5
- package/used-modules.txt +4 -0
@@ -1,16 +1,17 @@
|
|
1
|
+
import Log from '../../../base/Log.js';
|
2
|
+
import formatMessage from '../../../base/strings/formatMessage.js';
|
3
|
+
import deepEqual from '../../../base/util/deepEqual.js';
|
4
|
+
import extend from '../../../base/util/extend.js';
|
1
5
|
import CalendarType from '../CalendarType.js';
|
6
|
+
import Configuration from '../Configuration.js';
|
7
|
+
import Core from '../Core.js';
|
2
8
|
import Locale from '../Locale.js';
|
3
9
|
import LocaleData from '../LocaleData.js';
|
4
|
-
import UI5Date from '../date/UI5Date.js';
|
5
|
-
import UniversalDate from '../date/UniversalDate.js';
|
6
10
|
import CalendarUtils from '../date/CalendarUtils.js';
|
7
11
|
import CalendarWeekNumbering from '../date/CalendarWeekNumbering.js';
|
12
|
+
import UI5Date from '../date/UI5Date.js';
|
13
|
+
import UniversalDate from '../date/UniversalDate.js';
|
8
14
|
import TimezoneUtil from './TimezoneUtil.js';
|
9
|
-
import deepEqual from '../../../base/util/deepEqual.js';
|
10
|
-
import formatMessage from '../../../base/strings/formatMessage.js';
|
11
|
-
import Log from '../../../base/Log.js';
|
12
|
-
import extend from '../../../base/util/extend.js';
|
13
|
-
import Configuration from '../Configuration.js';
|
14
15
|
var DateFormat = function () {
|
15
16
|
throw new Error();
|
16
17
|
};
|
@@ -232,21 +233,23 @@ DateFormat.getDateTimeInstance = function (oFormatOptions, oLocale) {
|
|
232
233
|
};
|
233
234
|
DateFormat.getDateTimeWithTimezoneInstance = function (oFormatOptions, oLocale) {
|
234
235
|
if (oFormatOptions && !(oFormatOptions instanceof Locale)) {
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
if (
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
236
|
+
(function () {
|
237
|
+
oFormatOptions = Object.assign({}, oFormatOptions);
|
238
|
+
if (typeof oFormatOptions.showTimezone === 'string') {
|
239
|
+
var sShowTimezone = oFormatOptions.showTimezone;
|
240
|
+
if (oFormatOptions.showDate === undefined && oFormatOptions.showTime === undefined) {
|
241
|
+
if (sShowTimezone === 'Hide') {
|
242
|
+
oFormatOptions.showTimezone = false;
|
243
|
+
} else if (sShowTimezone === 'Only') {
|
244
|
+
oFormatOptions.showDate = false;
|
245
|
+
oFormatOptions.showTime = false;
|
246
|
+
}
|
244
247
|
}
|
248
|
+
oFormatOptions.showTimezone = sShowTimezone !== 'Hide';
|
245
249
|
}
|
246
|
-
|
247
|
-
}
|
250
|
+
}());
|
248
251
|
if (oFormatOptions.showDate === false && oFormatOptions.showTime === false && oFormatOptions.showTimezone === false) {
|
249
|
-
throw new TypeError('Invalid Configuration. One of the following format options must be true: showDate, showTime or showTimezone.');
|
252
|
+
throw new TypeError('Invalid Configuration. One of the following format options must be true: ' + 'showDate, showTime or showTimezone.');
|
250
253
|
}
|
251
254
|
}
|
252
255
|
return this.createInstance(oFormatOptions, oLocale, DateFormat._getDateTimeWithTimezoneInfo(oFormatOptions || {}));
|
@@ -299,13 +302,16 @@ DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo, bIsFallbac
|
|
299
302
|
}
|
300
303
|
}
|
301
304
|
if (oFormat.oFormatOptions.interval) {
|
305
|
+
var sSinglePattern, sDelimiter = oFormat.oFormatOptions.intervalDelimiter;
|
302
306
|
if (oFormat.oFormatOptions.format) {
|
303
307
|
oFormat.intervalPatterns = oFormat.oLocaleData.getCustomIntervalPattern(oFormat.oFormatOptions.format, null, oFormat.oFormatOptions.calendarType);
|
304
308
|
if (typeof oFormat.intervalPatterns === 'string') {
|
305
309
|
oFormat.intervalPatterns = [oFormat.intervalPatterns];
|
306
310
|
}
|
307
|
-
oFormat.
|
311
|
+
sSinglePattern = oFormat.oLocaleData.getCustomDateTimePattern(oFormat.oFormatOptions.format, oFormat.oFormatOptions.calendarType);
|
312
|
+
oFormat.intervalPatterns.push(sSinglePattern);
|
308
313
|
} else {
|
314
|
+
sSinglePattern = oFormat.oFormatOptions.pattern;
|
309
315
|
oFormat.intervalPatterns = [
|
310
316
|
oFormat.oLocaleData.getCombinedIntervalPattern(oFormat.oFormatOptions.pattern, oFormat.oFormatOptions.calendarType),
|
311
317
|
oFormat.oFormatOptions.pattern
|
@@ -313,6 +319,12 @@ DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo, bIsFallbac
|
|
313
319
|
}
|
314
320
|
var sCommonConnectorPattern = createIntervalPatternWithNormalConnector(oFormat);
|
315
321
|
oFormat.intervalPatterns.push(sCommonConnectorPattern);
|
322
|
+
if (sDelimiter) {
|
323
|
+
sDelimiter = sDelimiter.replace(/'/g, '\'\'');
|
324
|
+
sDelimiter = '\'' + sDelimiter + '\'';
|
325
|
+
oFormat.intervalPatterns.unshift(sSinglePattern + sDelimiter + sSinglePattern);
|
326
|
+
}
|
327
|
+
oFormat.intervalPatterns = Array.from(new Set(oFormat.intervalPatterns));
|
316
328
|
}
|
317
329
|
if (!bIsFallback) {
|
318
330
|
aFallbackFormatOptions = oInfo.aFallbackFormatOptions;
|
@@ -1524,25 +1536,31 @@ DateFormat.prototype.format = function (vJSDate, bUTC) {
|
|
1524
1536
|
}
|
1525
1537
|
return sResult;
|
1526
1538
|
};
|
1539
|
+
DateFormat.prototype._useCustomIntervalDelimiter = function (oDiffFields) {
|
1540
|
+
var aTokens;
|
1541
|
+
if (!this.oFormatOptions.intervalDelimiter) {
|
1542
|
+
return false;
|
1543
|
+
}
|
1544
|
+
if (this.oFormatOptions.format) {
|
1545
|
+
aTokens = this.oLocaleData._parseSkeletonFormat(this.oFormatOptions.format);
|
1546
|
+
return aTokens.some(function (oToken) {
|
1547
|
+
return oDiffFields[oToken.group];
|
1548
|
+
});
|
1549
|
+
}
|
1550
|
+
return true;
|
1551
|
+
};
|
1527
1552
|
DateFormat.prototype._formatInterval = function (aJSDates, bUTC) {
|
1528
|
-
var sCalendarType = this.oFormatOptions.calendarType
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
var sSymbol;
|
1534
|
-
var aBuffer = [];
|
1535
|
-
var sPattern;
|
1536
|
-
var aFormatArray = [];
|
1537
|
-
var oDiffField = this._getGreatestDiffField([
|
1538
|
-
oFromDate,
|
1539
|
-
oToDate
|
1540
|
-
]);
|
1541
|
-
if (!oDiffField) {
|
1553
|
+
var oDate, oPart, sPattern, sSymbol, aBuffer = [], sCalendarType = this.oFormatOptions.calendarType, aFormatArray = [], oFromDate = UniversalDate.getInstance(aJSDates[0], sCalendarType), oToDate = UniversalDate.getInstance(aJSDates[1], sCalendarType), oDiffFields = this._getDiffFields([
|
1554
|
+
oFromDate,
|
1555
|
+
oToDate
|
1556
|
+
]);
|
1557
|
+
if (!oDiffFields) {
|
1542
1558
|
return this._format(aJSDates[0], bUTC);
|
1543
1559
|
}
|
1544
|
-
if (this.
|
1545
|
-
sPattern = this.
|
1560
|
+
if (this._useCustomIntervalDelimiter(oDiffFields)) {
|
1561
|
+
sPattern = this.intervalPatterns[0];
|
1562
|
+
} else if (this.oFormatOptions.format) {
|
1563
|
+
sPattern = this.oLocaleData.getCustomIntervalPattern(this.oFormatOptions.format, oDiffFields, sCalendarType);
|
1546
1564
|
} else {
|
1547
1565
|
sPattern = this.oLocaleData.getCombinedIntervalPattern(this.oFormatOptions.pattern, sCalendarType);
|
1548
1566
|
}
|
@@ -1570,7 +1588,7 @@ var mFieldToGroup = {
|
|
1570
1588
|
Minutes: 'Minute',
|
1571
1589
|
Seconds: 'Second'
|
1572
1590
|
};
|
1573
|
-
DateFormat.prototype.
|
1591
|
+
DateFormat.prototype._getDiffFields = function (aDates) {
|
1574
1592
|
var bDiffFound = false, mDiff = {};
|
1575
1593
|
this.aIntervalCompareFields.forEach(function (sField) {
|
1576
1594
|
var sGetterPrefix = 'getUTC', sMethodName = sGetterPrefix + sField, sFieldGroup = mFieldToGroup[sField], vFromValue = aDates[0][sMethodName].apply(aDates[0]), vToValue = aDates[1][sMethodName].apply(aDates[1]);
|
@@ -2247,4 +2265,28 @@ DateFormat.prototype.getAllowedCharacters = function (aFormatArray) {
|
|
2247
2265
|
}
|
2248
2266
|
return sAllowedCharacters;
|
2249
2267
|
};
|
2268
|
+
DateFormat.prototype.getPlaceholderText = function () {
|
2269
|
+
var oResourceBundle = Core.getLibraryResourceBundle();
|
2270
|
+
return oResourceBundle.getText('date.placeholder', [this.format.apply(this, this.getSampleValue())]);
|
2271
|
+
};
|
2272
|
+
DateFormat.prototype.getSampleValue = function () {
|
2273
|
+
var oDate, iFullYear = UI5Date.getInstance().getFullYear(), bUTC = this.oFormatOptions.UTC;
|
2274
|
+
function getDate(iYear, iMonth, iDay, iHours, iMinutes, iSeconds, iMilliseconds) {
|
2275
|
+
return bUTC ? UI5Date.getInstance(Date.UTC(iYear, iMonth, iDay, iHours, iMinutes, iSeconds, iMilliseconds)) : UI5Date.getInstance(iYear, iMonth, iDay, iHours, iMinutes, iSeconds, iMilliseconds);
|
2276
|
+
}
|
2277
|
+
oDate = getDate(iFullYear, 11, 31, 23, 59, 58, 123);
|
2278
|
+
if (this.type === mDateFormatTypes.DATETIME_WITH_TIMEZONE) {
|
2279
|
+
return [
|
2280
|
+
oDate,
|
2281
|
+
Configuration.getTimezone()
|
2282
|
+
];
|
2283
|
+
}
|
2284
|
+
if (this.oFormatOptions.interval) {
|
2285
|
+
return [[
|
2286
|
+
getDate(iFullYear, 11, 22, 9, 12, 34, 567),
|
2287
|
+
oDate
|
2288
|
+
]];
|
2289
|
+
}
|
2290
|
+
return [oDate];
|
2291
|
+
};
|
2250
2292
|
export default DateFormat;
|
@@ -1,89 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
var aSupportedTimezoneIDs;
|
4
|
-
var oIntlDateTimeFormatCache = {
|
5
|
-
_oCache: new Map(),
|
6
|
-
_iCacheLimit: 10,
|
7
|
-
get: function (sTimezone) {
|
8
|
-
var cacheEntry = this._oCache.get(sTimezone);
|
9
|
-
if (cacheEntry) {
|
10
|
-
return cacheEntry;
|
11
|
-
}
|
12
|
-
var oOptions = {
|
13
|
-
hourCycle: "h23",
|
14
|
-
hour: "2-digit",
|
15
|
-
minute: "2-digit",
|
16
|
-
second: "2-digit",
|
17
|
-
fractionalSecondDigits: 3,
|
18
|
-
day: "2-digit",
|
19
|
-
month: "2-digit",
|
20
|
-
year: "numeric",
|
21
|
-
timeZone: sTimezone,
|
22
|
-
timeZoneName: "short",
|
23
|
-
era: "narrow",
|
24
|
-
weekday: "short"
|
25
|
-
};
|
26
|
-
var oInstance = new Intl.DateTimeFormat("en-US", oOptions);
|
27
|
-
if (this._oCache.size === this._iCacheLimit) {
|
28
|
-
this._oCache = new Map();
|
29
|
-
}
|
30
|
-
this._oCache.set(sTimezone, oInstance);
|
31
|
-
return oInstance;
|
32
|
-
}
|
33
|
-
};
|
34
|
-
TimezoneUtil.isValidTimezone = function (sTimezone) {
|
35
|
-
if (!sTimezone) {
|
36
|
-
return false;
|
37
|
-
}
|
38
|
-
if (Intl.supportedValuesOf) {
|
39
|
-
try {
|
40
|
-
aSupportedTimezoneIDs = aSupportedTimezoneIDs || Intl.supportedValuesOf("timeZone");
|
41
|
-
if (aSupportedTimezoneIDs.includes(sTimezone)) {
|
42
|
-
return true;
|
43
|
-
}
|
44
|
-
} catch (oError) {
|
45
|
-
aSupportedTimezoneIDs = [];
|
46
|
-
}
|
47
|
-
}
|
48
|
-
try {
|
49
|
-
oIntlDateTimeFormatCache.get(sTimezone);
|
50
|
-
return true;
|
51
|
-
} catch (oError) {
|
52
|
-
return false;
|
53
|
-
}
|
54
|
-
};
|
55
|
-
TimezoneUtil.convertToTimezone = function (oDate, sTargetTimezone) {
|
56
|
-
var oFormatParts = this._getParts(oDate, sTargetTimezone);
|
57
|
-
return TimezoneUtil._getDateFromParts(oFormatParts);
|
58
|
-
};
|
59
|
-
TimezoneUtil._getParts = function (oDate, sTargetTimezone) {
|
60
|
-
var sKey, oPart, oDateParts = Object.create(null), oIntlDate = oIntlDateTimeFormatCache.get(sTargetTimezone), oParts = oIntlDate.formatToParts(new Date(oDate.getTime()));
|
61
|
-
for (sKey in oParts) {
|
62
|
-
oPart = oParts[sKey];
|
63
|
-
if (oPart.type !== "literal") {
|
64
|
-
oDateParts[oPart.type] = oPart.value;
|
65
|
-
}
|
66
|
-
}
|
67
|
-
return oDateParts;
|
68
|
-
};
|
69
|
-
TimezoneUtil._getDateFromParts = function (oParts) {
|
70
|
-
var oDate = new Date(0), iUTCYear = parseInt(oParts.year);
|
71
|
-
if (oParts.era === "B") {
|
72
|
-
iUTCYear = iUTCYear * -1 + 1;
|
73
|
-
}
|
74
|
-
oDate.setUTCFullYear(iUTCYear, parseInt(oParts.month) - 1, parseInt(oParts.day));
|
75
|
-
oDate.setUTCHours(parseInt(oParts.hour), parseInt(oParts.minute), parseInt(oParts.second), parseInt(oParts.fractionalSecond || 0));
|
76
|
-
return oDate;
|
77
|
-
};
|
78
|
-
TimezoneUtil.calculateOffset = function (oDate, sTimezoneSource) {
|
79
|
-
var oFirstGuess = this.convertToTimezone(oDate, sTimezoneSource), iInitialOffset = oDate.getTime() - oFirstGuess.getTime(), oDateSource = new Date(oDate.getTime() + iInitialOffset), oDateTarget = this.convertToTimezone(oDateSource, sTimezoneSource);
|
80
|
-
return (oDateSource.getTime() - oDateTarget.getTime()) / 1000;
|
81
|
-
};
|
82
|
-
TimezoneUtil.getLocalTimezone = function () {
|
83
|
-
if (sLocalTimezone) {
|
84
|
-
return sLocalTimezone;
|
85
|
-
}
|
86
|
-
sLocalTimezone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
87
|
-
return sLocalTimezone;
|
88
|
-
};
|
89
|
-
export default TimezoneUtil;
|
1
|
+
import TimezoneUtils from '../../../base/i18n/date/TimezoneUtils.js';
|
2
|
+
export default TimezoneUtils;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-localization",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-c6c04c609",
|
4
4
|
"description": "Localization for UI5 Web Components",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -28,14 +28,14 @@
|
|
28
28
|
"prepublishOnly": "npm run clean && npm run build"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
|
-
"@openui5/sap.ui.core": "1.
|
32
|
-
"@ui5/webcomponents-tools": "0.0.0-
|
33
|
-
"chromedriver": "
|
31
|
+
"@openui5/sap.ui.core": "1.116.0",
|
32
|
+
"@ui5/webcomponents-tools": "0.0.0-c6c04c609",
|
33
|
+
"chromedriver": "119.0.1",
|
34
34
|
"mkdirp": "^1.0.4",
|
35
35
|
"resolve": "^1.20.0"
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
38
|
"@types/openui5": "^1.113.0",
|
39
|
-
"@ui5/webcomponents-base": "0.0.0-
|
39
|
+
"@ui5/webcomponents-base": "0.0.0-c6c04c609"
|
40
40
|
}
|
41
41
|
}
|
package/used-modules.txt
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
sap/base/Log.js
|
4
4
|
sap/base/assert.js
|
5
|
+
sap/base/i18n/LanguageTag.js
|
6
|
+
sap/base/i18n/date/CalendarWeekNumbering.js
|
7
|
+
sap/base/i18n/date/TimezoneUtils.js
|
8
|
+
sap/base/i18n/date/CalendarType.js
|
5
9
|
sap/base/strings/formatMessage.js
|
6
10
|
sap/base/util/ObjectPath.js
|
7
11
|
sap/base/util/array/uniqueSort.js
|