@ui5/webcomponents-localization 1.16.0-rc.0 → 1.16.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.16.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.1...v1.16.0-rc.2) (2023-07-20)
7
+
8
+ **Note:** Version bump only for package @ui5/webcomponents-localization
9
+
10
+
11
+
12
+
13
+
14
+ # [1.16.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.0...v1.16.0-rc.1) (2023-07-13)
15
+
16
+ **Note:** Version bump only for package @ui5/webcomponents-localization
17
+
18
+
19
+
20
+
21
+
6
22
  # [1.16.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.15.1...v1.16.0-rc.0) (2023-07-06)
7
23
 
8
24
  **Note:** Version bump only for package @ui5/webcomponents-localization
@@ -0,0 +1,35 @@
1
+ var rLanguageTag = /^((?:[A-Z]{2,3}(?:-[A-Z]{3}){0,3})|[A-Z]{4}|[A-Z]{5,8})(?:-([A-Z]{4}))?(?:-([A-Z]{2}|[0-9]{3}))?((?:-[0-9A-Z]{5,8}|-[0-9][0-9A-Z]{3})*)((?:-[0-9A-WYZ](?:-[0-9A-Z]{2,8})+)*)(?:-(X(?:-[0-9A-Z]{1,8})+))?$/i;
2
+ var LanguageTag = function (sLanguageTag) {
3
+ var aResult = rLanguageTag.exec(sLanguageTag.replace(/_/g, "-"));
4
+ if (aResult === null) {
5
+ throw new TypeError("The given language tag'" + sLanguageTag + "' does not adhere to BCP-47.");
6
+ }
7
+ this.language = aResult[1] || null;
8
+ this.script = aResult[2] || null;
9
+ this.region = aResult[3] || null;
10
+ this.variant = aResult[4] && aResult[4].slice(1) || null;
11
+ this.variantSubtags = this.variant ? this.variant.split("-") : [];
12
+ this.extension = aResult[5] && aResult[5].slice(1) || null;
13
+ this.extensionSubtags = this.variant ? this.variant.split("-") : [];
14
+ this.privateUse = aResult[6] || null;
15
+ this.privateUseSubtags = this.privateUse ? this.privateUse.slice(2).split("-") : [];
16
+ if (this.language) {
17
+ this.language = this.language.toLowerCase();
18
+ }
19
+ if (this.script) {
20
+ this.script = this.script.toLowerCase().replace(/^[a-z]/, function ($) {
21
+ return $.toUpperCase();
22
+ });
23
+ }
24
+ if (this.region) {
25
+ this.region = this.region.toUpperCase();
26
+ }
27
+ Object.freeze(this);
28
+ };
29
+ LanguageTag.prototype.toString = function () {
30
+ return join(this.language, this.script, this.region, this.variant, this.extension, this.privateUse);
31
+ };
32
+ function join() {
33
+ return Array.prototype.filter.call(arguments, Boolean).join("-");
34
+ }
35
+ export default LanguageTag;
@@ -0,0 +1,4 @@
1
+ declare const Localization: {
2
+ getModernLanguage: (sLanguage: string) => string;
3
+ };
4
+ export default Localization;
@@ -0,0 +1,12 @@
1
+ const M_ISO639_OLD_TO_NEW = {
2
+ "iw": "he",
3
+ "ji": "yi",
4
+ };
5
+ const getModernLanguage = (sLanguage) => {
6
+ return M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
7
+ };
8
+ const Localization = {
9
+ getModernLanguage,
10
+ };
11
+ export default Localization;
12
+ //# sourceMappingURL=Localization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Localization.js","sourceRoot":"","sources":["../../../../src/sap/base/i18n/Localization.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG;IAC3B,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;CACV,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC/C,OAAO,mBAAmB,CAAC,SAA6C,CAAC,IAAI,SAAS,CAAC;AACxF,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG;IACpB,iBAAiB;CACjB,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["const M_ISO639_OLD_TO_NEW = {\n\t\"iw\": \"he\",\n\t\"ji\": \"yi\",\n};\n\nconst getModernLanguage = (sLanguage: string) => {\n\treturn M_ISO639_OLD_TO_NEW[sLanguage as keyof typeof M_ISO639_OLD_TO_NEW] || sLanguage;\n};\n\nconst Localization = {\n\tgetModernLanguage,\n};\n\nexport default Localization;\n"]}
@@ -0,0 +1,8 @@
1
+ var CalendarType = {
2
+ Gregorian: "Gregorian",
3
+ Islamic: "Islamic",
4
+ Japanese: "Japanese",
5
+ Persian: "Persian",
6
+ Buddhist: "Buddhist"
7
+ };
8
+ export default CalendarType;
@@ -0,0 +1,30 @@
1
+ var CalendarWeekNumbering = {
2
+ Default: "Default",
3
+ ISO_8601: "ISO_8601",
4
+ MiddleEastern: "MiddleEastern",
5
+ WesternTraditional: "WesternTraditional"
6
+ };
7
+ Object.defineProperty(CalendarWeekNumbering, "getWeekConfigurationValues", {
8
+ value: function (sCalendarWeekNumbering) {
9
+ switch (sCalendarWeekNumbering) {
10
+ case CalendarWeekNumbering.ISO_8601:
11
+ return {
12
+ firstDayOfWeek: 1,
13
+ minimalDaysInFirstWeek: 4
14
+ };
15
+ case CalendarWeekNumbering.MiddleEastern:
16
+ return {
17
+ firstDayOfWeek: 6,
18
+ minimalDaysInFirstWeek: 1
19
+ };
20
+ case CalendarWeekNumbering.WesternTraditional:
21
+ return {
22
+ firstDayOfWeek: 0,
23
+ minimalDaysInFirstWeek: 1
24
+ };
25
+ default:
26
+ return undefined;
27
+ }
28
+ }
29
+ });
30
+ export default CalendarWeekNumbering;
@@ -0,0 +1,89 @@
1
+ var TimezoneUtils = {};
2
+ var sLocalTimezone = "";
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
+ TimezoneUtils.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
+ TimezoneUtils.convertToTimezone = function (oDate, sTargetTimezone) {
56
+ var oFormatParts = this._getParts(oDate, sTargetTimezone);
57
+ return TimezoneUtils._getDateFromParts(oFormatParts);
58
+ };
59
+ TimezoneUtils._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
+ TimezoneUtils._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
+ TimezoneUtils.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
+ TimezoneUtils.getLocalTimezone = function () {
83
+ if (sLocalTimezone) {
84
+ return sLocalTimezone;
85
+ }
86
+ sLocalTimezone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
87
+ return sLocalTimezone;
88
+ };
89
+ export default TimezoneUtils;
@@ -2,6 +2,9 @@ import ObjectPath from '../../base/util/ObjectPath.js';
2
2
  import assert from '../../base/assert.js';
3
3
  import Log from '../../base/Log.js';
4
4
  import uniqueSort from '../../base/util/array/uniqueSort.js';
5
+ function isFunction(obj) {
6
+ return typeof obj === 'function';
7
+ }
5
8
  var Metadata = function (sClassName, oClassInfo) {
6
9
  assert(typeof sClassName === 'string' && sClassName, 'Metadata: sClassName must be a non-empty string');
7
10
  assert(typeof oClassInfo === 'object', 'Metadata: oClassInfo must be empty or an object');
@@ -13,7 +16,7 @@ var Metadata = function (sClassName, oClassInfo) {
13
16
  oClassInfo.metadata.__version = 1;
14
17
  }
15
18
  oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2;
16
- if (typeof oClassInfo.constructor !== 'function') {
19
+ if (!isFunction(oClassInfo.constructor)) {
17
20
  throw Error('constructor for class ' + sClassName + ' must have been declared before creating metadata for it');
18
21
  }
19
22
  this._sClassName = sClassName;
@@ -27,9 +30,17 @@ Metadata.prototype.extend = function (oClassInfo) {
27
30
  Metadata.prototype.applySettings = function (oClassInfo) {
28
31
  var that = this, oStaticInfo = oClassInfo.metadata, oPrototype;
29
32
  if (oStaticInfo.baseType) {
30
- var oParentClass = ObjectPath.get(oStaticInfo.baseType);
31
- if (typeof oParentClass !== 'function') {
32
- Log.fatal('base class \'' + oStaticInfo.baseType + '\' does not exist');
33
+ var oParentClass;
34
+ if (isFunction(oStaticInfo.baseType)) {
35
+ oParentClass = oStaticInfo.baseType;
36
+ if (!isFunction(oParentClass.getMetadata)) {
37
+ throw new TypeError('baseType must be a UI5 class with a static getMetadata function');
38
+ }
39
+ } else {
40
+ oParentClass = ObjectPath.get(oStaticInfo.baseType);
41
+ if (!isFunction(oParentClass)) {
42
+ Log.fatal('base class \'' + oStaticInfo.baseType + '\' does not exist');
43
+ }
33
44
  }
34
45
  if (oParentClass.getMetadata) {
35
46
  this._oParent = oParentClass.getMetadata();
@@ -167,12 +178,12 @@ Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl
167
178
  sClassName = fnBaseClass;
168
179
  fnBaseClass = null;
169
180
  }
170
- assert(!fnBaseClass || typeof fnBaseClass === 'function');
181
+ assert(!fnBaseClass || isFunction(fnBaseClass));
171
182
  assert(typeof sClassName === 'string' && !!sClassName);
172
183
  assert(!oClassInfo || typeof oClassInfo === 'object');
173
- assert(!FNMetaImpl || typeof FNMetaImpl === 'function');
184
+ assert(!FNMetaImpl || isFunction(FNMetaImpl));
174
185
  FNMetaImpl = FNMetaImpl || Metadata;
175
- if (typeof FNMetaImpl.preprocessClassInfo === 'function') {
186
+ if (isFunction(FNMetaImpl.preprocessClassInfo)) {
176
187
  oClassInfo = FNMetaImpl.preprocessClassInfo(oClassInfo);
177
188
  }
178
189
  oClassInfo = oClassInfo || {};
@@ -181,7 +192,7 @@ Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl
181
192
  oClassInfo.constructor = undefined;
182
193
  }
183
194
  var fnClass = oClassInfo.constructor;
184
- assert(!fnClass || typeof fnClass === 'function');
195
+ assert(!fnClass || isFunction(fnClass));
185
196
  if (fnBaseClass) {
186
197
  if (!fnClass) {
187
198
  if (oClassInfo.metadata.deprecated) {
@@ -197,7 +208,7 @@ Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl
197
208
  }
198
209
  fnClass.prototype = Object.create(fnBaseClass.prototype);
199
210
  fnClass.prototype.constructor = fnClass;
200
- oClassInfo.metadata.baseType = fnBaseClass.getMetadata().getName();
211
+ oClassInfo.metadata.baseType = fnBaseClass;
201
212
  } else {
202
213
  fnClass = fnClass || function () {
203
214
  };
@@ -1,8 +1,2 @@
1
- var CalendarType = {
2
- Gregorian: "Gregorian",
3
- Islamic: "Islamic",
4
- Japanese: "Japanese",
5
- Persian: "Persian",
6
- Buddhist: "Buddhist"
7
- };
8
- export default CalendarType;
1
+ import CalendarType from '../../base/i18n/date/CalendarType.js';
2
+ export default CalendarType;
@@ -1,159 +1,62 @@
1
- import BaseObject from '../base/Object.js';
2
1
  import assert from '../../base/assert.js';
3
- import CalendarType from './CalendarType.js';
4
- var rLocale = /^((?:[A-Z]{2,3}(?:-[A-Z]{3}){0,3})|[A-Z]{4}|[A-Z]{5,8})(?:-([A-Z]{4}))?(?:-([A-Z]{2}|[0-9]{3}))?((?:-[0-9A-Z]{5,8}|-[0-9][0-9A-Z]{3})*)((?:-[0-9A-WYZ](?:-[0-9A-Z]{2,8})+)*)(?:-(X(?:-[0-9A-Z]{1,8})+))?$/i;
2
+ import BaseObject from '../base/Object.js';
3
+ import Localization from '../../base/i18n/Localization.js';
4
+ import LanguageTag from '../../base/i18n/LanguageTag.js';
5
5
  var Locale = BaseObject.extend('sap.ui.core.Locale', {
6
- constructor: function (sLocaleId) {
6
+ constructor: function (vLocale) {
7
7
  BaseObject.apply(this);
8
- var aResult = rLocale.exec(sLocaleId.replace(/_/g, '-'));
9
- if (aResult === null) {
10
- throw new TypeError('The given language \'' + sLocaleId + '\' does not adhere to BCP-47.');
11
- }
12
- this.sLocaleId = sLocaleId;
13
- this.sLanguage = aResult[1] || null;
14
- this.sScript = aResult[2] || null;
15
- this.sRegion = aResult[3] || null;
16
- this.sVariant = aResult[4] && aResult[4].slice(1) || null;
17
- this.sExtension = aResult[5] && aResult[5].slice(1) || null;
18
- this.sPrivateUse = aResult[6] || null;
19
- if (this.sLanguage) {
20
- this.sLanguage = this.sLanguage.toLowerCase();
21
- }
22
- if (this.sScript) {
23
- this.sScript = this.sScript.toLowerCase().replace(/^[a-z]/, function ($) {
24
- return $.toUpperCase();
25
- });
26
- }
27
- if (this.sRegion) {
28
- this.sRegion = this.sRegion.toUpperCase();
8
+ if (vLocale instanceof LanguageTag) {
9
+ this.oLanguageTag = vLocale;
10
+ this.sLocaleId = this.oLanguageTag.toString();
11
+ } else {
12
+ this.oLanguageTag = new LanguageTag(vLocale);
13
+ this.sLocaleId = vLocale;
29
14
  }
15
+ Object.assign(this, this.oLanguageTag);
16
+ this.sLanguage = this.language;
30
17
  },
31
18
  getLanguage: function () {
32
- return this.sLanguage;
19
+ return this.language;
33
20
  },
34
21
  getScript: function () {
35
- return this.sScript;
22
+ return this.script;
36
23
  },
37
24
  getRegion: function () {
38
- return this.sRegion;
25
+ return this.region;
39
26
  },
40
27
  getVariant: function () {
41
- return this.sVariant;
28
+ return this.variant;
42
29
  },
43
30
  getVariantSubtags: function () {
44
- return this.sVariant ? this.sVariant.split('-') : [];
31
+ return this.variantSubtags;
45
32
  },
46
33
  getExtension: function () {
47
- return this.sExtension;
34
+ return this.extension;
48
35
  },
49
36
  getExtensionSubtags: function () {
50
- return this.sExtension ? this.sExtension.slice(2).split('-') : [];
37
+ return this.extensionSubtags;
51
38
  },
52
39
  getPrivateUse: function () {
53
- return this.sPrivateUse;
40
+ return this.privateUse;
54
41
  },
55
42
  getPrivateUseSubtags: function () {
56
- return this.sPrivateUse ? this.sPrivateUse.slice(2).split('-') : [];
43
+ return this.privateUseSubtags;
57
44
  },
58
45
  hasPrivateUseSubtag: function (sSubtag) {
59
46
  assert(sSubtag && sSubtag.match(/^[0-9A-Z]{1,8}$/i), 'subtag must be a valid BCP47 private use tag');
60
- return this.getPrivateUseSubtags().indexOf(sSubtag) >= 0;
47
+ return this.privateUseSubtags.indexOf(sSubtag) >= 0;
61
48
  },
62
49
  toString: function () {
63
- return join(this.sLanguage, this.sScript, this.sRegion, this.sVariant, this.sExtension, this.sPrivateUse);
64
- },
65
- toLanguageTag: function () {
66
- var sLanguage = this.getModernLanguage();
67
- var sScript = this.sScript;
68
- if (sLanguage === 'sr' && sScript === 'Latn') {
69
- sLanguage = 'sh';
70
- sScript = null;
71
- }
72
- return join(sLanguage, sScript, this.sRegion, this.sVariant, this.sExtension, this.sPrivateUse);
73
- },
74
- getModernLanguage: function () {
75
- return M_ISO639_OLD_TO_NEW[this.sLanguage] || this.sLanguage;
50
+ return this.oLanguageTag.toString();
76
51
  },
77
52
  getSAPLogonLanguage: function () {
78
- return this._getSAPLogonLanguage();
79
- },
80
- _getSAPLogonLanguage: function () {
81
- var sLanguage = this.sLanguage || '';
82
- if (sLanguage.indexOf('-') >= 0) {
83
- sLanguage = sLanguage.slice(0, sLanguage.indexOf('-'));
84
- }
85
- sLanguage = M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
86
- if (sLanguage === 'zh' && !this.sScript && this.sRegion === 'TW') {
87
- return 'ZF';
88
- }
89
- return M_LOCALE_TO_ABAP_LANGUAGE[join(sLanguage, this.sScript)] || M_LOCALE_TO_ABAP_LANGUAGE[join(sLanguage, this.sRegion)] || M_LOCALE_TO_ABAP_LANGUAGE[getPseudoLanguageTag(this.sPrivateUse)] || sLanguage.toUpperCase();
90
- },
91
- getPreferredCalendarType: function () {
92
- return Locale._mPreferredCalendar[this.getLanguage() + '-' + this.getRegion()] || Locale._mPreferredCalendar[this.getLanguage()] || Locale._mPreferredCalendar['default'];
53
+ return Localization._getSAPLogonLanguage(this);
93
54
  }
94
55
  });
95
- function getPseudoLanguageTag(sPrivateUse) {
96
- if (sPrivateUse) {
97
- var m = /-(saptrc|sappsd|saprigi)(?:-|$)/i.exec(sPrivateUse);
98
- return m && 'en-US-x-' + m[1].toLowerCase();
99
- }
100
- }
101
- var M_ISO639_OLD_TO_NEW = {
102
- 'iw': 'he',
103
- 'ji': 'yi'
104
- };
105
- var M_ABAP_LANGUAGE_TO_LOCALE = {
106
- 'ZH': 'zh-Hans',
107
- 'ZF': 'zh-Hant',
108
- 'SH': 'sr-Latn',
109
- '6N': 'en-GB',
110
- '1P': 'pt-PT',
111
- '1X': 'es-MX',
112
- '3F': 'fr-CA',
113
- '1Q': 'en-US-x-saptrc',
114
- '2Q': 'en-US-x-sappsd',
115
- '3Q': 'en-US-x-saprigi'
116
- };
117
- var M_LOCALE_TO_ABAP_LANGUAGE = inverse(M_ABAP_LANGUAGE_TO_LOCALE);
118
- function getDesigntimePropertyAsArray(sValue) {
119
- var m = /\$([-a-z0-9A-Z._]+)(?::([^$]*))?\$/.exec(sValue);
120
- return m && m[2] ? m[2].split(/,/) : null;
121
- }
122
- var A_RTL_LOCALES = getDesigntimePropertyAsArray('$cldr-rtl-locales:ar,fa,he$') || [];
123
- Locale._cldrLocales = getDesigntimePropertyAsArray('$cldr-locales:ar,ar_EG,ar_SA,bg,ca,cy,cs,da,de,de_AT,de_CH,el,el_CY,en,en_AU,en_GB,en_HK,en_IE,en_IN,en_NZ,en_PG,en_SG,en_ZA,es,es_AR,es_BO,es_CL,es_CO,es_MX,es_PE,es_UY,es_VE,et,fa,fi,fr,fr_BE,fr_CA,fr_CH,fr_LU,he,hi,hr,hu,id,it,it_CH,ja,kk,ko,lt,lv,ms,nb,nl,nl_BE,pl,pt,pt_PT,ro,ru,ru_UA,sk,sl,sr,sr_Latn,sv,th,tr,uk,vi,zh_CN,zh_HK,zh_SG,zh_TW$');
124
- Locale._mPreferredCalendar = {
125
- 'ar-SA': CalendarType.Islamic,
126
- 'fa': CalendarType.Persian,
127
- 'th': CalendarType.Buddhist,
128
- 'default': CalendarType.Gregorian
129
- };
130
- Locale._coreI18nLocales = getDesigntimePropertyAsArray('$core-i18n-locales:,ar,bg,ca,cs,da,de,el,en,en_GB,es,es_MX,et,fi,fr,hi,hr,hu,it,iw,ja,kk,ko,lt,lv,ms,nl,no,pl,pt,ro,ru,sh,sk,sl,sv,th,tr,uk,vi,zh_CN,zh_TW$');
131
- Locale._impliesRTL = function (vLanguage) {
132
- var oLocale = vLanguage instanceof Locale ? vLanguage : new Locale(vLanguage);
133
- var sLanguage = oLocale.getLanguage() || '';
134
- sLanguage = sLanguage && M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
135
- var sRegion = oLocale.getRegion() || '';
136
- if (sRegion && A_RTL_LOCALES.indexOf(sLanguage + '_' + sRegion) >= 0) {
137
- return true;
138
- }
139
- return A_RTL_LOCALES.indexOf(sLanguage) >= 0;
140
- };
141
- Locale.fromSAPLogonLanguage = function (sSAPLogonLanguage) {
142
- if (sSAPLogonLanguage && typeof sSAPLogonLanguage === 'string') {
143
- sSAPLogonLanguage = M_ABAP_LANGUAGE_TO_LOCALE[sSAPLogonLanguage.toUpperCase()] || sSAPLogonLanguage;
144
- try {
145
- return new Locale(sSAPLogonLanguage);
146
- } catch (e) {
147
- }
56
+ Locale._getCoreLocale = function (oLocale) {
57
+ if (oLocale instanceof LanguageTag) {
58
+ oLocale = new Locale(oLocale);
148
59
  }
60
+ return oLocale;
149
61
  };
150
- function join() {
151
- return Array.prototype.filter.call(arguments, Boolean).join('-');
152
- }
153
- function inverse(obj) {
154
- return Object.keys(obj).reduce(function (inv, key) {
155
- inv[obj[key]] = key;
156
- return inv;
157
- }, {});
158
- }
159
62
  export default Locale;
@@ -1,12 +1,14 @@
1
1
  import Core from './Core.js';
2
- import extend from '../../base/util/extend.js';
3
- import BaseObject from '../base/Object.js';
4
2
  import CalendarType from './CalendarType.js';
5
3
  import Locale from './Locale.js';
6
4
  import assert from '../../base/assert.js';
5
+ import Localization from '../../base/i18n/Localization.js';
6
+ import extend from '../../base/util/extend.js';
7
7
  import LoaderExtensions from '../../base/util/LoaderExtensions.js';
8
+ import BaseObject from '../base/Object.js';
8
9
  import Configuration from './Configuration.js';
9
- var rEIgnoreCase = /e/i, mLegacyUnit2CurrentUnit = {
10
+ import CalendarWeekNumbering from './date/CalendarWeekNumbering.js';
11
+ var rCIgnoreCase = /c/i, rEIgnoreCase = /e/i, mLegacyUnit2CurrentUnit = {
10
12
  'acceleration-meter-per-second-squared': 'acceleration-meter-per-square-second',
11
13
  'concentr-milligram-per-deciliter': 'concentr-milligram-ofglucose-per-deciliter',
12
14
  'concentr-part-per-million': 'concentr-permillion',
@@ -18,9 +20,9 @@ var rEIgnoreCase = /e/i, mLegacyUnit2CurrentUnit = {
18
20
  }, rNumberInScientificNotation = /^([+-]?)((\d+)(?:\.(\d+))?)[eE]([+-]?\d+)$/, rTrailingZeroes = /0+$/;
19
21
  var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
20
22
  constructor: function (oLocale) {
21
- this.oLocale = oLocale;
23
+ this.oLocale = Locale._getCoreLocale(oLocale);
22
24
  BaseObject.apply(this);
23
- var oDataLoaded = getData(oLocale);
25
+ var oDataLoaded = getData(this.oLocale);
24
26
  this.mData = oDataLoaded.mData;
25
27
  this.sCLDRLocaleId = oDataLoaded.sCLDRLocaleId;
26
28
  },
@@ -46,7 +48,7 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
46
48
  getCurrentLanguageName: function () {
47
49
  var oLanguages = this.getLanguages();
48
50
  var sCurrentLanguage;
49
- var sLanguage = this.oLocale.getModernLanguage();
51
+ var sLanguage = Localization.getModernLanguage(this.oLocale.language);
50
52
  var sScript = this.oLocale.getScript();
51
53
  if (sLanguage === 'sr' && sScript === 'Latn') {
52
54
  sLanguage = 'sh';
@@ -837,11 +839,8 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
837
839
  aCategories.push('other');
838
840
  return aCategories;
839
841
  },
840
- getPluralCategory: function (sNumber) {
841
- var oPlurals = this._get('plurals');
842
- if (typeof sNumber === 'number') {
843
- sNumber = sNumber.toString();
844
- }
842
+ getPluralCategory: function (vNumber) {
843
+ var sNumber = typeof vNumber === 'number' ? vNumber.toString() : vNumber, oPlurals = this._get('plurals');
845
844
  if (!this._pluralTest) {
846
845
  this._pluralTest = {};
847
846
  }
@@ -987,7 +986,9 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
987
986
  throw new Error('Not completely parsed');
988
987
  }
989
988
  return function (sValue) {
990
- var iDotPos, iExponent, sFraction, sFractionNoZeros, sInteger, o, iExponentPos = sValue.search(rEIgnoreCase);
989
+ var iDotPos, iExponent, iExponentPos, sFraction, sFractionNoZeros, sInteger, o;
990
+ sValue = sValue.replace(rCIgnoreCase, 'e');
991
+ iExponentPos = sValue.search(rEIgnoreCase);
991
992
  iExponent = iExponentPos < 0 ? 0 : parseInt(sValue.slice(iExponentPos + 1));
992
993
  sValue = LocaleData.convertToDecimal(sValue);
993
994
  iDotPos = sValue.indexOf('.');
@@ -1266,12 +1267,13 @@ var mCLDRSymbols = {
1266
1267
  numericCeiling: 100
1267
1268
  }
1268
1269
  };
1269
- var M_ISO639_OLD_TO_NEW = {
1270
- 'iw': 'he',
1271
- 'ji': 'yi'
1272
- };
1270
+ function getDesigntimePropertyAsArray(sValue) {
1271
+ var m = /\$([-a-z0-9A-Z._]+)(?::([^$]*))?\$/.exec(sValue);
1272
+ return m && m[2] ? m[2].split(/,/) : null;
1273
+ }
1274
+ var _cldrLocales = getDesigntimePropertyAsArray('$cldr-locales:ar,ar_EG,ar_SA,bg,ca,cy,cs,da,de,de_AT,de_CH,el,el_CY,en,en_AU,en_GB,en_HK,en_IE,en_IN,en_NZ,en_PG,en_SG,en_ZA,es,es_AR,es_BO,es_CL,es_CO,es_MX,es_PE,es_UY,es_VE,et,fa,fi,fr,fr_BE,fr_CA,fr_CH,fr_LU,he,hi,hr,hu,id,it,it_CH,ja,kk,ko,lt,lv,ms,nb,nl,nl_BE,pl,pt,pt_PT,ro,ru,ru_UA,sk,sl,sr,sr_Latn,sv,th,tr,uk,vi,zh_CN,zh_HK,zh_SG,zh_TW$');
1273
1275
  var M_SUPPORTED_LOCALES = function () {
1274
- var LOCALES = Locale._cldrLocales, result = {}, i;
1276
+ var LOCALES = _cldrLocales, result = {}, i;
1275
1277
  if (LOCALES) {
1276
1278
  for (i = 0; i < LOCALES.length; i++) {
1277
1279
  result[LOCALES[i]] = true;
@@ -1340,7 +1342,7 @@ function getData(oLocale) {
1340
1342
  }
1341
1343
  return mLocaleDatas[sId];
1342
1344
  }
1343
- sLanguage = sLanguage && M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
1345
+ sLanguage = sLanguage && Localization.getModernLanguage(sLanguage) || sLanguage;
1344
1346
  if (sLanguage === 'no') {
1345
1347
  sLanguage = 'nb';
1346
1348
  }
@@ -1401,9 +1403,25 @@ var CustomLocaleData = LocaleData.extend('sap.ui.core.CustomLocaleData', {
1401
1403
  var mData = this._getDeep(this.mData, arguments);
1402
1404
  var mCustomData = this._getDeep(this.mCustomData, arguments);
1403
1405
  return extend({}, mData, mCustomData);
1406
+ },
1407
+ getFirstDayOfWeek: function () {
1408
+ var sCalendarWeekNumbering = Configuration.getCalendarWeekNumbering();
1409
+ if (sCalendarWeekNumbering === CalendarWeekNumbering.Default) {
1410
+ return LocaleData.prototype.getFirstDayOfWeek.call(this);
1411
+ }
1412
+ return CalendarWeekNumbering.getWeekConfigurationValues(sCalendarWeekNumbering).firstDayOfWeek;
1413
+ },
1414
+ getMinimalDaysInFirstWeek: function () {
1415
+ var sCalendarWeekNumbering = Configuration.getCalendarWeekNumbering();
1416
+ if (sCalendarWeekNumbering === CalendarWeekNumbering.Default) {
1417
+ return LocaleData.prototype.getMinimalDaysInFirstWeek.call(this);
1418
+ }
1419
+ return CalendarWeekNumbering.getWeekConfigurationValues(sCalendarWeekNumbering).minimalDaysInFirstWeek;
1404
1420
  }
1405
1421
  });
1406
1422
  LocaleData.getInstance = function (oLocale) {
1423
+ oLocale = Locale._getCoreLocale(oLocale);
1407
1424
  return oLocale.hasPrivateUseSubtag('sapufmt') ? new CustomLocaleData(oLocale) : new LocaleData(oLocale);
1408
1425
  };
1426
+ LocaleData._cldrLocales = _cldrLocales;
1409
1427
  export default LocaleData;
@@ -1,27 +1,16 @@
1
1
  import CalendarWeekNumbering from './CalendarWeekNumbering.js';
2
2
  import Configuration from '../Configuration.js';
3
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
4
  var CalendarUtils = {
19
5
  getWeekConfigurationValues: function (sCalendarWeekNumbering, oLocale) {
20
- var oLocaleData;
21
- if (mWeekNumberingConfiguration.hasOwnProperty(sCalendarWeekNumbering)) {
22
- return mWeekNumberingConfiguration[sCalendarWeekNumbering];
6
+ var oLocaleData, oWeekConfigurationValues;
7
+ if (!sCalendarWeekNumbering) {
8
+ return CalendarUtils.getWeekConfigurationValues(Configuration.getCalendarWeekNumbering(), oLocale);
9
+ }
10
+ oWeekConfigurationValues = CalendarWeekNumbering.getWeekConfigurationValues(sCalendarWeekNumbering);
11
+ if (oWeekConfigurationValues) {
12
+ return oWeekConfigurationValues;
23
13
  }
24
- sCalendarWeekNumbering = sCalendarWeekNumbering || CalendarWeekNumbering.Default;
25
14
  if (sCalendarWeekNumbering === CalendarWeekNumbering.Default) {
26
15
  oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
27
16
  oLocaleData = LocaleData.getInstance(oLocale);
@@ -1,7 +1,2 @@
1
- var CalendarWeekNumbering = {
2
- Default: "Default",
3
- ISO_8601: "ISO_8601",
4
- MiddleEastern: "MiddleEastern",
5
- WesternTraditional: "WesternTraditional"
6
- };
7
- export default CalendarWeekNumbering;
1
+ import CalendarWeekNumbering from '../../../base/i18n/date/CalendarWeekNumbering.js';
2
+ export default CalendarWeekNumbering;
@@ -124,20 +124,16 @@ UniversalDate.prototype.getUTCEra = function () {
124
124
  UniversalDate.prototype.setUTCEra = function (iEra) {
125
125
  };
126
126
  UniversalDate.prototype.getWeek = function (oLocale, vCalendarWeekNumbering) {
127
- checkWeekConfig(vCalendarWeekNumbering);
128
127
  return UniversalDate.getWeekByDate(this.sCalendarType, this.getFullYear(), this.getMonth(), this.getDate(), oLocale, vCalendarWeekNumbering);
129
128
  };
130
129
  UniversalDate.prototype.setWeek = function (oWeek, oLocale, vCalendarWeekNumbering) {
131
- checkWeekConfig(vCalendarWeekNumbering);
132
130
  var oDate = UniversalDate.getFirstDateOfWeek(this.sCalendarType, oWeek.year || this.getFullYear(), oWeek.week, oLocale, vCalendarWeekNumbering);
133
131
  this.setFullYear(oDate.year, oDate.month, oDate.day);
134
132
  };
135
133
  UniversalDate.prototype.getUTCWeek = function (oLocale, vCalendarWeekNumbering) {
136
- checkWeekConfig(vCalendarWeekNumbering);
137
134
  return UniversalDate.getWeekByDate(this.sCalendarType, this.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate(), oLocale, vCalendarWeekNumbering);
138
135
  };
139
136
  UniversalDate.prototype.setUTCWeek = function (oWeek, oLocale, vCalendarWeekNumbering) {
140
- checkWeekConfig(vCalendarWeekNumbering);
141
137
  var oDate = UniversalDate.getFirstDateOfWeek(this.sCalendarType, oWeek.year || this.getFullYear(), oWeek.week, oLocale, vCalendarWeekNumbering);
142
138
  this.setUTCFullYear(oDate.year, oDate.month, oDate.day);
143
139
  };
@@ -173,6 +169,7 @@ UniversalDate.prototype.getTimezoneLong = function () {
173
169
  };
174
170
  var iMillisecondsInWeek = 7 * 24 * 60 * 60 * 1000;
175
171
  UniversalDate.getWeekByDate = function (sCalendarType, iYear, iMonth, iDay, oLocale, vCalendarWeekNumbering) {
172
+ vCalendarWeekNumbering = vCalendarWeekNumbering || Configuration.getCalendarWeekNumbering();
176
173
  checkWeekConfig(vCalendarWeekNumbering);
177
174
  oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
178
175
  var clDate = this.getClass(sCalendarType);
@@ -203,6 +200,7 @@ UniversalDate.getWeekByDate = function (sCalendarType, iYear, iMonth, iDay, oLoc
203
200
  };
204
201
  };
205
202
  UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek, oLocale, vCalendarWeekNumbering) {
203
+ vCalendarWeekNumbering = vCalendarWeekNumbering || Configuration.getCalendarWeekNumbering();
206
204
  checkWeekConfig(vCalendarWeekNumbering);
207
205
  oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
208
206
  var clDate = this.getClass(sCalendarType);
@@ -223,27 +221,18 @@ UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek, oLocal
223
221
  };
224
222
  };
225
223
  function isSplitWeek(vCalendarWeekNumbering, oLocale) {
226
- oLocale = oLocale || Configuration.getFormatSettings().getFormatLocale();
227
224
  var oLocaleData = LocaleData.getInstance(oLocale);
228
- return (!isCalendarWeekConfigurationDefined(vCalendarWeekNumbering) || vCalendarWeekNumbering === CalendarWeekNumbering.Default) && oLocaleData.firstDayStartsFirstWeek();
225
+ return (vCalendarWeekNumbering === CalendarWeekNumbering.Default || vCalendarWeekNumbering === CalendarWeekNumbering.WesternTraditional) && oLocaleData.firstDayStartsFirstWeek();
229
226
  }
230
227
  function checkWeekConfig(vCalendarWeekNumbering) {
231
228
  if (typeof vCalendarWeekNumbering === 'object') {
232
- if (!isCalendarWeekConfigurationDefined(vCalendarWeekNumbering)) {
229
+ if (typeof vCalendarWeekNumbering.firstDayOfWeek !== 'number' || typeof vCalendarWeekNumbering.minimalDaysInFirstWeek !== 'number') {
233
230
  throw new TypeError('Week config requires firstDayOfWeek and minimalDaysInFirstWeek to be set');
234
231
  }
235
- } else if (vCalendarWeekNumbering && !Object.values(CalendarWeekNumbering).includes(vCalendarWeekNumbering)) {
232
+ } else if (!Object.values(CalendarWeekNumbering).includes(vCalendarWeekNumbering)) {
236
233
  throw new TypeError('Illegal format option calendarWeekNumbering: \'' + vCalendarWeekNumbering + '\'');
237
234
  }
238
235
  }
239
- function isCalendarWeekConfigurationDefined(vCalendarWeekNumbering) {
240
- if (typeof vCalendarWeekNumbering === 'object') {
241
- return typeof vCalendarWeekNumbering.firstDayOfWeek === 'number' && typeof vCalendarWeekNumbering.minimalDaysInFirstWeek === 'number';
242
- } else if (vCalendarWeekNumbering) {
243
- return true;
244
- }
245
- return false;
246
- }
247
236
  function resolveCalendarWeekConfiguration(vCalendarWeekNumbering, oLocale) {
248
237
  if (typeof vCalendarWeekNumbering === 'object' && typeof vCalendarWeekNumbering.firstDayOfWeek === 'number' && typeof vCalendarWeekNumbering.minimalDaysInFirstWeek === 'number') {
249
238
  return vCalendarWeekNumbering;
@@ -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
- oFormatOptions = Object.assign({}, oFormatOptions);
236
- if (typeof oFormatOptions.showTimezone === 'string') {
237
- var sShowTimezone = oFormatOptions.showTimezone;
238
- if (oFormatOptions.showDate === undefined && oFormatOptions.showTime === undefined) {
239
- if (sShowTimezone === 'Hide') {
240
- oFormatOptions.showTimezone = false;
241
- } else if (sShowTimezone === 'Only') {
242
- oFormatOptions.showDate = false;
243
- oFormatOptions.showTime = false;
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
- oFormatOptions.showTimezone = sShowTimezone !== 'Hide';
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.intervalPatterns.push(oFormat.oLocaleData.getCustomDateTimePattern(oFormat.oFormatOptions.format, oFormat.oFormatOptions.calendarType));
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
- var oFromDate = UniversalDate.getInstance(aJSDates[0], sCalendarType);
1530
- var oToDate = UniversalDate.getInstance(aJSDates[1], sCalendarType);
1531
- var oDate;
1532
- var oPart;
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.oFormatOptions.format) {
1545
- sPattern = this.oLocaleData.getCustomIntervalPattern(this.oFormatOptions.format, oDiffField, sCalendarType);
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._getGreatestDiffField = function (aDates) {
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
- var TimezoneUtil = {};
2
- var sLocalTimezone = "";
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": "1.16.0-rc.0",
3
+ "version": "1.16.0-rc.2",
4
4
  "description": "Localization for UI5 Web Components",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -28,15 +28,15 @@
28
28
  "prepublishOnly": "npm run clean && npm run build"
29
29
  },
30
30
  "devDependencies": {
31
- "@openui5/sap.ui.core": "1.112.0",
32
- "@ui5/webcomponents-tools": "1.16.0-rc.0",
31
+ "@openui5/sap.ui.core": "1.116.0",
32
+ "@ui5/webcomponents-tools": "1.16.0-rc.2",
33
33
  "chromedriver": "113.0.0",
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": "1.16.0-rc.0"
39
+ "@ui5/webcomponents-base": "1.16.0-rc.2"
40
40
  },
41
- "gitHead": "e23cbd36eb33781f2315e850473f56e6268a7861"
41
+ "gitHead": "99936618ab8cb389307b76b60eab9ad9f0f4a5c1"
42
42
  }
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