@ui5/webcomponents-localization 1.7.4 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/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/sap/base/Log.js +28 -29
- package/dist/sap/base/assert.js +5 -6
- package/dist/sap/ui/core/Configuration.js +21 -0
- package/dist/sap/ui/core/Core.js +2 -27
- package/dist/sap/ui/core/FormatSettings.js +15 -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.json +5 -5
- package/src/sap/ui/core/Configuration.js +21 -0
- package/src/sap/ui/core/Core.js +2 -27
- package/src/sap/ui/core/FormatSettings.js +15 -0
- package/used-modules.txt +2 -0
- package/global.d.ts +0 -105
- package/src/DateFormat.ts +0 -3
- package/src/LocaleData.ts +0 -8
- package/src/dates/CalendarDate.ts +0 -231
- package/src/getCachedLocaleDataInstance.ts +0 -14
package/dist/sap/base/Log.js
CHANGED
@@ -10,7 +10,7 @@ Log.Level = {
|
|
10
10
|
TRACE: 5,
|
11
11
|
ALL: 5 + 1
|
12
12
|
};
|
13
|
-
var
|
13
|
+
var aLog = [], mMaxLevel = { '': Log.Level.ERROR }, iLogEntriesLimit = 3000, oListener = null, bLogSupportInfo = false;
|
14
14
|
function pad0(i, w) {
|
15
15
|
return ('000' + String(i)).slice(-w);
|
16
16
|
}
|
@@ -72,26 +72,26 @@ function getLogEntryListenerInstance() {
|
|
72
72
|
}
|
73
73
|
return oListener;
|
74
74
|
}
|
75
|
-
Log.fatal = function (sMessage,
|
76
|
-
log(Log.Level.FATAL, sMessage,
|
75
|
+
Log.fatal = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
76
|
+
log(Log.Level.FATAL, sMessage, vDetails, sComponent, fnSupportInfo);
|
77
77
|
};
|
78
|
-
Log.error = function (sMessage,
|
79
|
-
log(Log.Level.ERROR, sMessage,
|
78
|
+
Log.error = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
79
|
+
log(Log.Level.ERROR, sMessage, vDetails, sComponent, fnSupportInfo);
|
80
80
|
};
|
81
|
-
Log.warning = function (sMessage,
|
82
|
-
log(Log.Level.WARNING, sMessage,
|
81
|
+
Log.warning = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
82
|
+
log(Log.Level.WARNING, sMessage, vDetails, sComponent, fnSupportInfo);
|
83
83
|
};
|
84
|
-
Log.info = function (sMessage,
|
85
|
-
log(Log.Level.INFO, sMessage,
|
84
|
+
Log.info = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
85
|
+
log(Log.Level.INFO, sMessage, vDetails, sComponent, fnSupportInfo);
|
86
86
|
};
|
87
|
-
Log.debug = function (sMessage,
|
88
|
-
log(Log.Level.DEBUG, sMessage,
|
87
|
+
Log.debug = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
88
|
+
log(Log.Level.DEBUG, sMessage, vDetails, sComponent, fnSupportInfo);
|
89
89
|
};
|
90
|
-
Log.trace = function (sMessage,
|
91
|
-
log(Log.Level.TRACE, sMessage,
|
90
|
+
Log.trace = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
91
|
+
log(Log.Level.TRACE, sMessage, vDetails, sComponent, fnSupportInfo);
|
92
92
|
};
|
93
93
|
Log.setLevel = function (iLogLevel, sComponent, _bDefault) {
|
94
|
-
sComponent = sComponent ||
|
94
|
+
sComponent = sComponent || '';
|
95
95
|
if (!_bDefault || mMaxLevel[sComponent] == null) {
|
96
96
|
mMaxLevel[sComponent] = iLogLevel;
|
97
97
|
var sLogLevel;
|
@@ -104,24 +104,23 @@ Log.setLevel = function (iLogLevel, sComponent, _bDefault) {
|
|
104
104
|
}
|
105
105
|
};
|
106
106
|
Log.getLevel = function (sComponent) {
|
107
|
-
return level(sComponent
|
107
|
+
return level(sComponent);
|
108
108
|
};
|
109
109
|
Log.isLoggable = function (iLevel, sComponent) {
|
110
|
-
return (iLevel == null ? Log.Level.DEBUG : iLevel) <= level(sComponent
|
110
|
+
return (iLevel == null ? Log.Level.DEBUG : iLevel) <= level(sComponent);
|
111
111
|
};
|
112
112
|
Log.logSupportInfo = function (bEnabled) {
|
113
113
|
bLogSupportInfo = bEnabled;
|
114
114
|
};
|
115
|
-
function log(iLevel, sMessage,
|
116
|
-
if (!fnSupportInfo && !sComponent && typeof
|
117
|
-
fnSupportInfo =
|
118
|
-
|
115
|
+
function log(iLevel, sMessage, vDetails, sComponent, fnSupportInfo) {
|
116
|
+
if (!fnSupportInfo && !sComponent && typeof vDetails === 'function') {
|
117
|
+
fnSupportInfo = vDetails;
|
118
|
+
vDetails = '';
|
119
119
|
}
|
120
120
|
if (!fnSupportInfo && typeof sComponent === 'function') {
|
121
121
|
fnSupportInfo = sComponent;
|
122
122
|
sComponent = '';
|
123
123
|
}
|
124
|
-
sComponent = sComponent || sDefaultComponent;
|
125
124
|
if (iLevel <= level(sComponent)) {
|
126
125
|
var fNow = now(), oNow = new Date(fNow), iMicroSeconds = Math.floor((fNow - Math.floor(fNow)) * 1000), oLogEntry = {
|
127
126
|
time: pad0(oNow.getHours(), 2) + ':' + pad0(oNow.getMinutes(), 2) + ':' + pad0(oNow.getSeconds(), 2) + '.' + pad0(oNow.getMilliseconds(), 3) + pad0(iMicroSeconds, 3),
|
@@ -129,7 +128,7 @@ function log(iLevel, sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
129
128
|
timestamp: fNow,
|
130
129
|
level: iLevel,
|
131
130
|
message: String(sMessage || ''),
|
132
|
-
details: String(
|
131
|
+
details: String(vDetails || ''),
|
133
132
|
component: String(sComponent || '')
|
134
133
|
};
|
135
134
|
if (bLogSupportInfo && typeof fnSupportInfo === 'function') {
|
@@ -145,27 +144,27 @@ function log(iLevel, sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
145
144
|
oListener.onLogEntry(oLogEntry);
|
146
145
|
}
|
147
146
|
if (console) {
|
148
|
-
var isDetailsError =
|
147
|
+
var isDetailsError = vDetails instanceof Error, logText = oLogEntry.date + ' ' + oLogEntry.time + ' ' + oLogEntry.message + ' - ' + oLogEntry.details + ' ' + oLogEntry.component;
|
149
148
|
switch (iLevel) {
|
150
149
|
case Log.Level.FATAL:
|
151
150
|
case Log.Level.ERROR:
|
152
|
-
isDetailsError ? console.error(logText, '\n',
|
151
|
+
isDetailsError ? console.error(logText, '\n', vDetails) : console.error(logText);
|
153
152
|
break;
|
154
153
|
case Log.Level.WARNING:
|
155
|
-
isDetailsError ? console.warn(logText, '\n',
|
154
|
+
isDetailsError ? console.warn(logText, '\n', vDetails) : console.warn(logText);
|
156
155
|
break;
|
157
156
|
case Log.Level.INFO:
|
158
157
|
if (console.info) {
|
159
|
-
isDetailsError ? console.info(logText, '\n',
|
158
|
+
isDetailsError ? console.info(logText, '\n', vDetails) : console.info(logText);
|
160
159
|
} else {
|
161
|
-
isDetailsError ? console.log(logText, '\n',
|
160
|
+
isDetailsError ? console.log(logText, '\n', vDetails) : console.log(logText);
|
162
161
|
}
|
163
162
|
break;
|
164
163
|
case Log.Level.DEBUG:
|
165
|
-
isDetailsError ? console.debug(logText, '\n',
|
164
|
+
isDetailsError ? console.debug(logText, '\n', vDetails) : console.debug(logText);
|
166
165
|
break;
|
167
166
|
case Log.Level.TRACE:
|
168
|
-
isDetailsError ? console.trace(logText, '\n',
|
167
|
+
isDetailsError ? console.trace(logText, '\n', vDetails) : console.trace(logText);
|
169
168
|
break;
|
170
169
|
}
|
171
170
|
if (console.info && oLogEntry.supportInfo) {
|
package/dist/sap/base/assert.js
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import Log from './Log.js';
|
2
1
|
var fnAssert = function (bResult, vMessage) {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
if (!bResult) {
|
3
|
+
var sMessage = typeof vMessage === "function" ? vMessage() : vMessage;
|
4
|
+
console.assert(bResult, sMessage);
|
5
|
+
}
|
7
6
|
};
|
8
|
-
export default fnAssert;
|
7
|
+
export default fnAssert;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
|
2
|
+
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
|
3
|
+
import getDesigntimePropertyAsArray from "@ui5/webcomponents-base/dist/util/getDesigntimePropertyAsArray.js";
|
4
|
+
import TimezoneUtil from "./format/TimezoneUtil.js";
|
5
|
+
import FormatSettings from "./FormatSettings.js";
|
6
|
+
|
7
|
+
const emptyFn = () => { };
|
8
|
+
|
9
|
+
/**
|
10
|
+
* OpenUI5 Configuration Shim
|
11
|
+
*/
|
12
|
+
const Configuration = {
|
13
|
+
getLanguage,
|
14
|
+
getCalendarType,
|
15
|
+
getSupportedLanguages: () => getDesigntimePropertyAsArray("$core-i18n-locales:,ar,bg,ca,cs,da,de,el,en,es,et,fi,fr,hi,hr,hu,it,iw,ja,ko,lt,lv,nl,no,pl,pt,ro,ru,sh,sk,sl,sv,th,tr,uk,vi,zh_CN,zh_TW$"),
|
16
|
+
getOriginInfo: emptyFn,
|
17
|
+
getFormatSettings: () => FormatSettings,
|
18
|
+
getTimezone: () => TimezoneUtil.getLocalTimezone(),
|
19
|
+
};
|
20
|
+
|
21
|
+
export default Configuration;
|
package/dist/sap/ui/core/Core.js
CHANGED
@@ -1,33 +1,8 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import getDesigntimePropertyAsArray from "@ui5/webcomponents-base/dist/util/getDesigntimePropertyAsArray.js";
|
4
|
-
import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
|
5
|
-
import TimezoneUtil from "./format/TimezoneUtil.js";
|
1
|
+
import FormatSettings from "./FormatSettings.js";
|
2
|
+
import Configuration from "./Configuration.js";
|
6
3
|
|
7
4
|
const emptyFn = () => {};
|
8
5
|
|
9
|
-
/**
|
10
|
-
* OpenUI5 FormatSettings shim
|
11
|
-
*/
|
12
|
-
const FormatSettings = {
|
13
|
-
getFormatLocale: getLocale,
|
14
|
-
getLegacyDateFormat: emptyFn,
|
15
|
-
getLegacyDateCalendarCustomizing: emptyFn,
|
16
|
-
getCustomLocaleData: emptyFn,
|
17
|
-
};
|
18
|
-
|
19
|
-
/**
|
20
|
-
* OpenUI5 Configuration Shim
|
21
|
-
*/
|
22
|
-
const Configuration = {
|
23
|
-
getLanguage,
|
24
|
-
getCalendarType,
|
25
|
-
getSupportedLanguages: () => getDesigntimePropertyAsArray("$core-i18n-locales:,ar,bg,ca,cs,da,de,el,en,es,et,fi,fr,hi,hr,hu,it,iw,ja,ko,lt,lv,nl,no,pl,pt,ro,ru,sh,sk,sl,sv,th,tr,uk,vi,zh_CN,zh_TW$"),
|
26
|
-
getOriginInfo: emptyFn,
|
27
|
-
getFormatSettings: () => FormatSettings,
|
28
|
-
getTimezone: () => TimezoneUtil.getLocalTimezone(),
|
29
|
-
};
|
30
|
-
|
31
6
|
/**
|
32
7
|
* OpenUI5 Core shim
|
33
8
|
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
|
2
|
+
|
3
|
+
const emptyFn = () => {};
|
4
|
+
|
5
|
+
/**
|
6
|
+
* OpenUI5 FormatSettings shim
|
7
|
+
*/
|
8
|
+
const FormatSettings = {
|
9
|
+
getFormatLocale: getLocale,
|
10
|
+
getLegacyDateFormat: emptyFn,
|
11
|
+
getLegacyDateCalendarCustomizing: emptyFn,
|
12
|
+
getCustomLocaleData: emptyFn,
|
13
|
+
};
|
14
|
+
|
15
|
+
export default FormatSettings;
|
@@ -75,6 +75,9 @@ var Locale = BaseObject.extend('sap.ui.core.Locale', {
|
|
75
75
|
return M_ISO639_OLD_TO_NEW[this.sLanguage] || this.sLanguage;
|
76
76
|
},
|
77
77
|
getSAPLogonLanguage: function () {
|
78
|
+
return this._getSAPLogonLanguage();
|
79
|
+
},
|
80
|
+
_getSAPLogonLanguage: function () {
|
78
81
|
var sLanguage = this.sLanguage || '';
|
79
82
|
if (sLanguage.indexOf('-') >= 0) {
|
80
83
|
sLanguage = sLanguage.slice(0, sLanguage.indexOf('-'));
|
@@ -5,6 +5,7 @@ import CalendarType from './CalendarType.js';
|
|
5
5
|
import Locale from './Locale.js';
|
6
6
|
import assert from '../../base/assert.js';
|
7
7
|
import LoaderExtensions from '../../base/util/LoaderExtensions.js';
|
8
|
+
import Configuration from './Configuration.js';
|
8
9
|
var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
9
10
|
constructor: function (oLocale) {
|
10
11
|
this.oLocale = oLocale;
|
@@ -97,6 +98,56 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
97
98
|
assert(sStyle == 'short' || sStyle == 'medium' || sStyle == 'long' || sStyle == 'full', 'sStyle must be short, medium, long or full');
|
98
99
|
return this._get(getCLDRCalendarName(sCalendarType), 'dateFormats', sStyle);
|
99
100
|
},
|
101
|
+
getFlexibleDayPeriods: function (sWidth, sCalendarType) {
|
102
|
+
return this._get(getCLDRCalendarName(sCalendarType), 'flexibleDayPeriods', 'format', sWidth);
|
103
|
+
},
|
104
|
+
getFlexibleDayPeriodsStandAlone: function (sWidth, sCalendarType) {
|
105
|
+
return this._get(getCLDRCalendarName(sCalendarType), 'flexibleDayPeriods', 'stand-alone', sWidth);
|
106
|
+
},
|
107
|
+
getFlexibleDayPeriodOfTime: function (iHour, iMinute) {
|
108
|
+
var iAbsoluteMinutes, oDayPeriodRules, sPeriodMatch;
|
109
|
+
iAbsoluteMinutes = (iHour * 60 + iMinute) % 1440;
|
110
|
+
oDayPeriodRules = this._get('dayPeriodRules');
|
111
|
+
function parseToAbsoluteMinutes(sValue) {
|
112
|
+
var aSplit = sValue.split(':'), sHour = aSplit[0], sMinute = aSplit[1];
|
113
|
+
return parseInt(sHour) * 60 + parseInt(sMinute);
|
114
|
+
}
|
115
|
+
sPeriodMatch = Object.keys(oDayPeriodRules).find(function (sDayPeriodRule) {
|
116
|
+
var oDayPeriodRule = oDayPeriodRules[sDayPeriodRule];
|
117
|
+
return oDayPeriodRule['_at'] && parseToAbsoluteMinutes(oDayPeriodRule['_at']) === iAbsoluteMinutes;
|
118
|
+
});
|
119
|
+
if (sPeriodMatch) {
|
120
|
+
return sPeriodMatch;
|
121
|
+
}
|
122
|
+
return Object.keys(oDayPeriodRules).find(function (sDayPeriodRule) {
|
123
|
+
var iEndValue, aIntervals, iStartValue, oDayPeriodRule = oDayPeriodRules[sDayPeriodRule];
|
124
|
+
if (oDayPeriodRule['_at']) {
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
iStartValue = parseToAbsoluteMinutes(oDayPeriodRule['_from']);
|
128
|
+
iEndValue = parseToAbsoluteMinutes(oDayPeriodRule['_before']);
|
129
|
+
if (iStartValue > iEndValue) {
|
130
|
+
aIntervals = [
|
131
|
+
{
|
132
|
+
start: iStartValue,
|
133
|
+
end: 1440
|
134
|
+
},
|
135
|
+
{
|
136
|
+
start: 0,
|
137
|
+
end: iEndValue
|
138
|
+
}
|
139
|
+
];
|
140
|
+
} else {
|
141
|
+
aIntervals = [{
|
142
|
+
start: iStartValue,
|
143
|
+
end: iEndValue
|
144
|
+
}];
|
145
|
+
}
|
146
|
+
return aIntervals.some(function (oInterval) {
|
147
|
+
return oInterval.start <= iAbsoluteMinutes && oInterval.end > iAbsoluteMinutes;
|
148
|
+
});
|
149
|
+
});
|
150
|
+
},
|
100
151
|
getTimePattern: function (sStyle, sCalendarType) {
|
101
152
|
assert(sStyle == 'short' || sStyle == 'medium' || sStyle == 'long' || sStyle == 'full', 'sStyle must be short, medium, long or full');
|
102
153
|
return this._get(getCLDRCalendarName(sCalendarType), 'timeFormats', sStyle);
|
@@ -125,6 +176,10 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
125
176
|
this._appendItems(aPatterns, aMissingTokens);
|
126
177
|
return aPatterns[0];
|
127
178
|
},
|
179
|
+
getTimezoneTranslations: function () {
|
180
|
+
this.mTimezoneTranslations = this.mTimezoneTranslations || _resolveTimezoneTranslationStructure(this._get('timezoneNames'));
|
181
|
+
return Object.assign({}, this.mTimezoneTranslations);
|
182
|
+
},
|
128
183
|
getCustomDateTimePattern: function (sSkeleton, sCalendarType) {
|
129
184
|
var oAvailableFormats = this._get(getCLDRCalendarName(sCalendarType), 'dateTimeFormats', 'availableFormats');
|
130
185
|
return this._getFormatPattern(sSkeleton, oAvailableFormats, sCalendarType);
|
@@ -743,7 +798,7 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
743
798
|
return oMessageBundle.getText(sKey, iWeekNumber);
|
744
799
|
},
|
745
800
|
firstDayStartsFirstWeek: function () {
|
746
|
-
return this.
|
801
|
+
return this.oLocale.getLanguage() === 'en' && this.oLocale.getRegion() === 'US';
|
747
802
|
},
|
748
803
|
getPreferredCalendarType: function () {
|
749
804
|
var sCalendarPreference = this._get('calendarPreference'), aCalendars = sCalendarPreference ? sCalendarPreference.split(' ') : [], sCalendarName, sType, i;
|
@@ -1171,9 +1226,29 @@ var M_SUPPORTED_LOCALES = function () {
|
|
1171
1226
|
return result;
|
1172
1227
|
}();
|
1173
1228
|
var mLocaleDatas = {};
|
1229
|
+
function _resolveTimezoneTranslationStructure(oNode, sKey, oResult, aParentTranslations) {
|
1230
|
+
aParentTranslations = aParentTranslations ? aParentTranslations.slice() : [];
|
1231
|
+
oResult = oResult || {};
|
1232
|
+
sKey = sKey || '';
|
1233
|
+
Object.keys(oNode).forEach(function (sChildKey) {
|
1234
|
+
var vChildNode = oNode[sChildKey];
|
1235
|
+
if (typeof vChildNode === 'object') {
|
1236
|
+
var aParentTranslationForChild = aParentTranslations.slice();
|
1237
|
+
var sParent = vChildNode['_parent'];
|
1238
|
+
if (sParent) {
|
1239
|
+
aParentTranslationForChild.push(sParent);
|
1240
|
+
}
|
1241
|
+
_resolveTimezoneTranslationStructure(vChildNode, sKey + sChildKey + '/', oResult, aParentTranslationForChild);
|
1242
|
+
} else if (typeof vChildNode === 'string' && sChildKey !== '_parent') {
|
1243
|
+
var sParents = aParentTranslations.length ? aParentTranslations.join(', ') + ', ' : '';
|
1244
|
+
oResult[sKey + sChildKey] = sParents + vChildNode;
|
1245
|
+
}
|
1246
|
+
});
|
1247
|
+
return oResult;
|
1248
|
+
}
|
1174
1249
|
function getCLDRCalendarName(sCalendarType) {
|
1175
1250
|
if (!sCalendarType) {
|
1176
|
-
sCalendarType =
|
1251
|
+
sCalendarType = Configuration.getCalendarType();
|
1177
1252
|
}
|
1178
1253
|
return 'ca-' + sCalendarType.toLowerCase();
|
1179
1254
|
}
|
@@ -1248,7 +1323,7 @@ function getData(oLocale) {
|
|
1248
1323
|
var CustomLocaleData = LocaleData.extend('sap.ui.core.CustomLocaleData', {
|
1249
1324
|
constructor: function (oLocale) {
|
1250
1325
|
LocaleData.apply(this, arguments);
|
1251
|
-
this.mCustomData =
|
1326
|
+
this.mCustomData = Configuration.getFormatSettings().getCustomLocaleData();
|
1252
1327
|
},
|
1253
1328
|
_get: function () {
|
1254
1329
|
var aArguments = Array.prototype.slice.call(arguments), sCalendar, sKey;
|
@@ -117,11 +117,5 @@ Buddhist.prototype.setUTCFullYear = function (iYear, iMonth, iDay) {
|
|
117
117
|
}
|
118
118
|
return this._setUTCBuddhist(oBuddhist);
|
119
119
|
};
|
120
|
-
Buddhist.prototype.getWeek = function () {
|
121
|
-
return UniversalDate.getWeekByDate(this.sCalendarType, this.oDate.getFullYear(), this.getMonth(), this.getDate());
|
122
|
-
};
|
123
|
-
Buddhist.prototype.getUTCWeek = function () {
|
124
|
-
return UniversalDate.getWeekByDate(this.sCalendarType, this.oDate.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate());
|
125
|
-
};
|
126
120
|
_Calendars.set(CalendarType.Buddhist, Buddhist);
|
127
121
|
export default Buddhist;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import CalendarWeekNumbering from './CalendarWeekNumbering.js';
|
2
|
+
import Configuration from '../Configuration.js';
|
3
|
+
import LocaleData from '../LocaleData.js';
|
4
|
+
var mWeekNumberingConfiguration = {
|
5
|
+
ISO_8601: {
|
6
|
+
firstDayOfWeek: 1,
|
7
|
+
minimalDaysInFirstWeek: 4
|
8
|
+
},
|
9
|
+
MiddleEastern: {
|
10
|
+
firstDayOfWeek: 6,
|
11
|
+
minimalDaysInFirstWeek: 1
|
12
|
+
},
|
13
|
+
WesternTraditional: {
|
14
|
+
firstDayOfWeek: 0,
|
15
|
+
minimalDaysInFirstWeek: 1
|
16
|
+
}
|
17
|
+
};
|
18
|
+
var CalendarUtils = {
|
19
|
+
getWeekConfigurationValues: function (sCalendarWeekNumbering, oLocale) {
|
20
|
+
var oLocaleData;
|
21
|
+
if (mWeekNumberingConfiguration.hasOwnProperty(sCalendarWeekNumbering)) {
|
22
|
+
return mWeekNumberingConfiguration[sCalendarWeekNumbering];
|
23
|
+
}
|
24
|
+
sCalendarWeekNumbering = sCalendarWeekNumbering || CalendarWeekNumbering.Default;
|
25
|
+
if (sCalendarWeekNumbering === CalendarWeekNumbering.Default) {
|
26
|
+
oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
|
27
|
+
oLocaleData = LocaleData.getInstance(oLocale);
|
28
|
+
return {
|
29
|
+
firstDayOfWeek: oLocaleData.getFirstDayOfWeek(),
|
30
|
+
minimalDaysInFirstWeek: oLocaleData.getMinimalDaysInFirstWeek()
|
31
|
+
};
|
32
|
+
}
|
33
|
+
return undefined;
|
34
|
+
}
|
35
|
+
};
|
36
|
+
export default CalendarUtils;
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import Core from '../Core.js';
|
2
1
|
import UniversalDate from './UniversalDate.js';
|
3
2
|
import CalendarType from '../CalendarType.js';
|
4
3
|
import Log from '../../../base/Log.js';
|
5
4
|
import _Calendars from './_Calendars.js';
|
5
|
+
import Configuration from '../Configuration.js';
|
6
6
|
var Islamic = UniversalDate.extend('sap.ui.core.date.Islamic', {
|
7
7
|
constructor: function () {
|
8
8
|
var aArgs = arguments;
|
@@ -102,9 +102,9 @@ function toGregorianArguments(aArgs) {
|
|
102
102
|
function initCustomizationMap() {
|
103
103
|
var sDateFormat, oCustomizationJSON;
|
104
104
|
oCustomizationMap = {};
|
105
|
-
sDateFormat =
|
105
|
+
sDateFormat = Configuration.getFormatSettings().getLegacyDateFormat();
|
106
106
|
sDateFormat = _isSupportedIslamicCalendarType(sDateFormat) ? sDateFormat : 'A';
|
107
|
-
oCustomizationJSON =
|
107
|
+
oCustomizationJSON = Configuration.getFormatSettings().getLegacyDateCalendarCustomizing();
|
108
108
|
oCustomizationJSON = oCustomizationJSON || [];
|
109
109
|
if (!oCustomizationJSON.length) {
|
110
110
|
Log.warning('No calendar customizations.');
|
@@ -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]) {
|