@ui5/webcomponents-localization 0.0.0-974b11d82 → 0.0.0-97c4a1259

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.
Files changed (167) hide show
  1. package/.eslintignore +1 -1
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +273 -0
  4. package/dist/Assets-static.js.map +1 -1
  5. package/dist/Assets.js.map +1 -1
  6. package/dist/DateFormat.js.map +1 -1
  7. package/dist/LocaleData.js.map +1 -1
  8. package/dist/dates/CalendarDate.d.ts +7 -5
  9. package/dist/dates/CalendarDate.js +8 -7
  10. package/dist/dates/CalendarDate.js.map +1 -1
  11. package/dist/dates/ExtremeDates.d.ts +2 -2
  12. package/dist/dates/ExtremeDates.js.map +1 -1
  13. package/dist/dates/UI5Date.d.ts +6 -0
  14. package/dist/dates/UI5Date.js +7 -0
  15. package/dist/dates/UI5Date.js.map +1 -0
  16. package/dist/dates/UniversalDate.d.ts +2 -1
  17. package/dist/dates/UniversalDate.js.map +1 -1
  18. package/dist/dates/calculateWeekNumber.d.ts +2 -1
  19. package/dist/dates/calculateWeekNumber.js.map +1 -1
  20. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +1 -1
  21. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -1
  22. package/dist/dates/getDaysInMonth.js.map +1 -1
  23. package/dist/dates/getRoundedTimestamp.js +1 -0
  24. package/dist/dates/getRoundedTimestamp.js.map +1 -1
  25. package/dist/dates/getTodayUTCTimestamp.d.ts +1 -1
  26. package/dist/dates/getTodayUTCTimestamp.js +2 -1
  27. package/dist/dates/getTodayUTCTimestamp.js.map +1 -1
  28. package/dist/dates/modifyDateBy.d.ts +2 -1
  29. package/dist/dates/modifyDateBy.js +34 -19
  30. package/dist/dates/modifyDateBy.js.map +1 -1
  31. package/dist/dates/transformDateToSecondaryType.d.ts +1 -1
  32. package/dist/dates/transformDateToSecondaryType.js +3 -2
  33. package/dist/dates/transformDateToSecondaryType.js.map +1 -1
  34. package/dist/features/calendar/Buddhist.js.map +1 -1
  35. package/dist/features/calendar/Gregorian.js.map +1 -1
  36. package/dist/features/calendar/Islamic.js.map +1 -1
  37. package/dist/features/calendar/Japanese.js.map +1 -1
  38. package/dist/features/calendar/Persian.js.map +1 -1
  39. package/dist/generated/assets/cldr/ar.json +5531 -6704
  40. package/dist/generated/assets/cldr/ar_EG.json +5531 -6704
  41. package/dist/generated/assets/cldr/ar_SA.json +5530 -6704
  42. package/dist/generated/assets/cldr/bg.json +4452 -5742
  43. package/dist/generated/assets/cldr/ca.json +4440 -5793
  44. package/dist/generated/assets/cldr/cs.json +4960 -6294
  45. package/dist/generated/assets/cldr/cy.json +5211 -6612
  46. package/dist/generated/assets/cldr/da.json +4308 -5651
  47. package/dist/generated/assets/cldr/de.json +4313 -5713
  48. package/dist/generated/assets/cldr/de_AT.json +4314 -5714
  49. package/dist/generated/assets/cldr/de_CH.json +4312 -5712
  50. package/dist/generated/assets/cldr/el.json +4281 -5579
  51. package/dist/generated/assets/cldr/el_CY.json +4281 -5579
  52. package/dist/generated/assets/cldr/en.json +4316 -5732
  53. package/dist/generated/assets/cldr/en_AU.json +4319 -5724
  54. package/dist/generated/assets/cldr/en_GB.json +4329 -5733
  55. package/dist/generated/assets/cldr/en_HK.json +4337 -5739
  56. package/dist/generated/assets/cldr/en_IE.json +4328 -5733
  57. package/dist/generated/assets/cldr/en_IN.json +4333 -5734
  58. package/dist/generated/assets/cldr/en_NZ.json +4328 -5733
  59. package/dist/generated/assets/cldr/en_PG.json +4329 -5734
  60. package/dist/generated/assets/cldr/en_SG.json +4333 -5735
  61. package/dist/generated/assets/cldr/en_ZA.json +4329 -5734
  62. package/dist/generated/assets/cldr/es.json +4331 -5641
  63. package/dist/generated/assets/cldr/es_AR.json +4334 -5643
  64. package/dist/generated/assets/cldr/es_BO.json +4333 -5642
  65. package/dist/generated/assets/cldr/es_CL.json +4334 -5643
  66. package/dist/generated/assets/cldr/es_CO.json +4333 -5642
  67. package/dist/generated/assets/cldr/es_MX.json +4335 -5644
  68. package/dist/generated/assets/cldr/es_PE.json +4333 -5642
  69. package/dist/generated/assets/cldr/es_UY.json +4335 -5644
  70. package/dist/generated/assets/cldr/es_VE.json +4334 -5643
  71. package/dist/generated/assets/cldr/et.json +4340 -5729
  72. package/dist/generated/assets/cldr/fa.json +4367 -5647
  73. package/dist/generated/assets/cldr/fi.json +4463 -5804
  74. package/dist/generated/assets/cldr/fr.json +4357 -5741
  75. package/dist/generated/assets/cldr/fr_BE.json +4357 -5741
  76. package/dist/generated/assets/cldr/fr_CA.json +4351 -5735
  77. package/dist/generated/assets/cldr/fr_CH.json +4375 -5759
  78. package/dist/generated/assets/cldr/fr_LU.json +4357 -5741
  79. package/dist/generated/assets/cldr/he.json +4869 -6175
  80. package/dist/generated/assets/cldr/hi.json +4295 -5558
  81. package/dist/generated/assets/cldr/hr.json +4583 -5681
  82. package/dist/generated/assets/cldr/hu.json +4364 -5686
  83. package/dist/generated/assets/cldr/id.json +4060 -5420
  84. package/dist/generated/assets/cldr/it.json +4299 -5712
  85. package/dist/generated/assets/cldr/it_CH.json +4299 -5712
  86. package/dist/generated/assets/cldr/ja.json +4211 -5626
  87. package/dist/generated/assets/cldr/kk.json +4339 -5487
  88. package/dist/generated/assets/cldr/ko.json +4189 -5534
  89. package/dist/generated/assets/cldr/lt.json +4850 -6243
  90. package/dist/generated/assets/cldr/lv.json +4587 -5874
  91. package/dist/generated/assets/cldr/ms.json +4021 -5245
  92. package/dist/generated/assets/cldr/nb.json +4335 -5740
  93. package/dist/generated/assets/cldr/nl.json +4294 -5613
  94. package/dist/generated/assets/cldr/nl_BE.json +4294 -5613
  95. package/dist/generated/assets/cldr/pl.json +4667 -5972
  96. package/dist/generated/assets/cldr/pt.json +4235 -5567
  97. package/dist/generated/assets/cldr/pt_PT.json +4372 -5702
  98. package/dist/generated/assets/cldr/ro.json +4563 -5852
  99. package/dist/generated/assets/cldr/ru.json +4909 -6169
  100. package/dist/generated/assets/cldr/ru_UA.json +4909 -6169
  101. package/dist/generated/assets/cldr/sk.json +4939 -6166
  102. package/dist/generated/assets/cldr/sl.json +4910 -6136
  103. package/dist/generated/assets/cldr/sr.json +4585 -5888
  104. package/dist/generated/assets/cldr/sr_Latn.json +4574 -5889
  105. package/dist/generated/assets/cldr/sv.json +4362 -5774
  106. package/dist/generated/assets/cldr/th.json +4214 -5627
  107. package/dist/generated/assets/cldr/tr.json +4400 -5809
  108. package/dist/generated/assets/cldr/uk.json +4858 -6115
  109. package/dist/generated/assets/cldr/vi.json +4070 -5435
  110. package/dist/generated/assets/cldr/zh_CN.json +4100 -5429
  111. package/dist/generated/assets/cldr/zh_HK.json +4108 -5437
  112. package/dist/generated/assets/cldr/zh_SG.json +4108 -5437
  113. package/dist/generated/assets/cldr/zh_TW.json +4131 -5525
  114. package/dist/getCachedLocaleDataInstance.js.map +1 -1
  115. package/dist/locale/getLocaleData.js.map +1 -1
  116. package/dist/sap/base/i18n/LanguageTag.js +35 -0
  117. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  118. package/dist/sap/base/i18n/Localization.js +12 -0
  119. package/dist/sap/base/i18n/Localization.js.map +1 -0
  120. package/dist/sap/base/i18n/date/CalendarType.js +8 -0
  121. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +30 -0
  122. package/dist/sap/base/i18n/date/TimezoneUtils.js +89 -0
  123. package/dist/sap/base/util/LoaderExtensions.js.map +1 -1
  124. package/dist/sap/ui/base/Metadata.js +20 -9
  125. package/dist/sap/ui/core/CalendarType.js +2 -8
  126. package/dist/sap/ui/core/Configuration.js +2 -1
  127. package/dist/sap/ui/core/Configuration.js.map +1 -1
  128. package/dist/sap/ui/core/Core.js.map +1 -1
  129. package/dist/sap/ui/core/FormatSettings.js.map +1 -1
  130. package/dist/sap/ui/core/Locale.js +28 -125
  131. package/dist/sap/ui/core/LocaleData.js +107 -35
  132. package/dist/sap/ui/core/date/CalendarUtils.js +7 -18
  133. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +2 -7
  134. package/dist/sap/ui/core/date/UI5Date.js +305 -0
  135. package/dist/sap/ui/core/date/UniversalDate.js +12 -22
  136. package/dist/sap/ui/core/format/DateFormat.js +385 -329
  137. package/dist/sap/ui/core/format/TimezoneUtil.js +2 -94
  138. package/{package-scripts.js → package-scripts.cjs} +2 -3
  139. package/package.json +7 -6
  140. package/tsconfig.json +1 -0
  141. package/used-modules.txt +5 -0
  142. package/src/Assets-static.ts +0 -2
  143. package/src/Assets.ts +0 -2
  144. package/src/DateFormat.ts +0 -8
  145. package/src/LocaleData.ts +0 -8
  146. package/src/dates/CalendarDate.ts +0 -232
  147. package/src/dates/ExtremeDates.ts +0 -40
  148. package/src/dates/UniversalDate.ts +0 -51
  149. package/src/dates/calculateWeekNumber.ts +0 -53
  150. package/src/dates/convertMonthNumbersToMonthNames.ts +0 -34
  151. package/src/dates/getDaysInMonth.ts +0 -11
  152. package/src/dates/getRoundedTimestamp.ts +0 -14
  153. package/src/dates/getTodayUTCTimestamp.ts +0 -10
  154. package/src/dates/modifyDateBy.ts +0 -42
  155. package/src/dates/transformDateToSecondaryType.ts +0 -21
  156. package/src/features/calendar/Buddhist.ts +0 -1
  157. package/src/features/calendar/Gregorian.ts +0 -1
  158. package/src/features/calendar/Islamic.ts +0 -1
  159. package/src/features/calendar/Japanese.ts +0 -1
  160. package/src/features/calendar/Persian.ts +0 -1
  161. package/src/getCachedLocaleDataInstance.ts +0 -15
  162. package/src/locale/getLocaleData.ts +0 -28
  163. package/src/sap/base/util/LoaderExtensions.ts +0 -17
  164. package/src/sap/ui/core/Configuration.ts +0 -22
  165. package/src/sap/ui/core/Core.ts +0 -15
  166. package/src/sap/ui/core/FormatSettings.ts +0 -16
  167. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -1,16 +1,28 @@
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';
10
+ import CalendarWeekNumbering from './date/CalendarWeekNumbering.js';
11
+ var rCIgnoreCase = /c/i, rEIgnoreCase = /e/i, mLegacyUnit2CurrentUnit = {
12
+ 'acceleration-meter-per-second-squared': 'acceleration-meter-per-square-second',
13
+ 'concentr-milligram-per-deciliter': 'concentr-milligram-ofglucose-per-deciliter',
14
+ 'concentr-part-per-million': 'concentr-permillion',
15
+ 'consumption-liter-per-100kilometers': 'consumption-liter-per-100-kilometer',
16
+ 'pressure-millimeter-of-mercury': 'pressure-millimeter-ofhg',
17
+ 'pressure-pound-per-square-inch': 'pressure-pound-force-per-square-inch',
18
+ 'pressure-inch-hg': 'pressure-inch-ofhg',
19
+ 'torque-pound-foot': 'torque-pound-force-foot'
20
+ }, rNumberInScientificNotation = /^([+-]?)((\d+)(?:\.(\d+))?)[eE]([+-]?\d+)$/, rTrailingZeroes = /0+$/;
9
21
  var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
10
22
  constructor: function (oLocale) {
11
- this.oLocale = oLocale;
23
+ this.oLocale = Locale._getCoreLocale(oLocale);
12
24
  BaseObject.apply(this);
13
- var oDataLoaded = getData(oLocale);
25
+ var oDataLoaded = getData(this.oLocale);
14
26
  this.mData = oDataLoaded.mData;
15
27
  this.sCLDRLocaleId = oDataLoaded.sCLDRLocaleId;
16
28
  },
@@ -36,7 +48,7 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
36
48
  getCurrentLanguageName: function () {
37
49
  var oLanguages = this.getLanguages();
38
50
  var sCurrentLanguage;
39
- var sLanguage = this.oLocale.getModernLanguage();
51
+ var sLanguage = Localization.getModernLanguage(this.oLocale.language);
40
52
  var sScript = this.oLocale.getScript();
41
53
  if (sLanguage === 'sr' && sScript === 'Latn') {
42
54
  sLanguage = 'sh';
@@ -642,11 +654,14 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
642
654
  oTimeEntry = oScale[sEntry];
643
655
  iSign = sEntry.substr(18) === 'past' ? -1 : 1;
644
656
  aPluralCategories.forEach(function (sKey) {
645
- aPatterns.push({
646
- scale: sScale,
647
- sign: iSign,
648
- pattern: oTimeEntry['relativeTimePattern-count-' + sKey]
649
- });
657
+ var sPattern = oTimeEntry['relativeTimePattern-count-' + sKey];
658
+ if (sPattern) {
659
+ aPatterns.push({
660
+ scale: sScale,
661
+ sign: iSign,
662
+ pattern: sPattern
663
+ });
664
+ }
650
665
  });
651
666
  }
652
667
  }
@@ -769,7 +784,11 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
769
784
  return this.getUnitFormat(sUnit);
770
785
  },
771
786
  getUnitFormat: function (sUnit) {
772
- return this._get('units', 'short', sUnit);
787
+ var oResult = this._get('units', 'short', sUnit);
788
+ if (!oResult && mLegacyUnit2CurrentUnit[sUnit]) {
789
+ oResult = this._get('units', 'short', mLegacyUnit2CurrentUnit[sUnit]);
790
+ }
791
+ return oResult;
773
792
  },
774
793
  getUnitFormats: function () {
775
794
  return this._getMerged('units', 'short');
@@ -801,7 +820,7 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
801
820
  return this.oLocale.getLanguage() === 'en' && this.oLocale.getRegion() === 'US';
802
821
  },
803
822
  getPreferredCalendarType: function () {
804
- var sCalendarPreference = this._get('calendarPreference'), aCalendars = sCalendarPreference ? sCalendarPreference.split(' ') : [], sCalendarName, sType, i;
823
+ var sCalendarName, sType, i, aCalendars = this._get('calendarPreference') || [];
805
824
  for (i = 0; i < aCalendars.length; i++) {
806
825
  sCalendarName = aCalendars[i].split('-')[0];
807
826
  for (sType in CalendarType) {
@@ -820,11 +839,8 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
820
839
  aCategories.push('other');
821
840
  return aCategories;
822
841
  },
823
- getPluralCategory: function (sNumber) {
824
- var oPlurals = this._get('plurals');
825
- if (typeof sNumber === 'number') {
826
- sNumber = sNumber.toString();
827
- }
842
+ getPluralCategory: function (vNumber) {
843
+ var sNumber = typeof vNumber === 'number' ? vNumber.toString() : vNumber, oPlurals = this._get('plurals');
828
844
  if (!this._pluralTest) {
829
845
  this._pluralTest = {};
830
846
  }
@@ -834,14 +850,14 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
834
850
  fnTest = this._parsePluralRule(oPlurals[sCategory]);
835
851
  this._pluralTest[sCategory] = fnTest;
836
852
  }
837
- if (fnTest(sNumber)) {
853
+ if (fnTest(sNumber).bMatch) {
838
854
  return sCategory;
839
855
  }
840
856
  }
841
857
  return 'other';
842
858
  },
843
859
  _parsePluralRule: function (sRule) {
844
- var OP_OR = 'or', OP_AND = 'and', OP_MOD = '%', OP_EQ = '=', OP_NEQ = '!=', OPD_N = 'n', OPD_I = 'i', OPD_F = 'f', OPD_T = 't', OPD_V = 'v', OPD_W = 'w', RANGE = '..', SEP = ',';
860
+ var OP_OR = 'or', OP_AND = 'and', OP_MOD = '%', OP_EQ = '=', OP_NEQ = '!=', OPD_N = 'n', OPD_I = 'i', OPD_F = 'f', OPD_T = 't', OPD_V = 'v', OPD_W = 'w', OPD_C = 'c', OPD_E = 'e', RANGE = '..', SEP = ',';
845
861
  var i = 0, aTokens;
846
862
  aTokens = sRule.split(' ');
847
863
  function accept(sToken) {
@@ -935,6 +951,14 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
935
951
  return function (o) {
936
952
  return o.w;
937
953
  };
954
+ } else if (accept(OPD_C)) {
955
+ return function (o) {
956
+ return o.c;
957
+ };
958
+ } else if (accept(OPD_E)) {
959
+ return function (o) {
960
+ return o.c;
961
+ };
938
962
  } else {
939
963
  throw new Error('Unknown operand: ' + consume());
940
964
  }
@@ -962,28 +986,59 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
962
986
  throw new Error('Not completely parsed');
963
987
  }
964
988
  return function (sValue) {
965
- var iDotPos = sValue.indexOf('.'), sDecimal, sFraction, sFractionNoZeros, o;
989
+ var iDotPos, iExponent, iExponentPos, sFraction, sFractionNoZeros, sInteger, o;
990
+ sValue = sValue.replace(rCIgnoreCase, 'e');
991
+ iExponentPos = sValue.search(rEIgnoreCase);
992
+ iExponent = iExponentPos < 0 ? 0 : parseInt(sValue.slice(iExponentPos + 1));
993
+ sValue = LocaleData.convertToDecimal(sValue);
994
+ iDotPos = sValue.indexOf('.');
966
995
  if (iDotPos === -1) {
967
- sDecimal = sValue;
996
+ sInteger = sValue;
968
997
  sFraction = '';
969
998
  sFractionNoZeros = '';
970
999
  } else {
971
- sDecimal = sValue.substr(0, iDotPos);
972
- sFraction = sValue.substr(iDotPos + 1);
973
- sFractionNoZeros = sFraction.replace(/0+$/, '');
1000
+ sInteger = sValue.slice(0, iDotPos);
1001
+ sFraction = sValue.slice(iDotPos + 1);
1002
+ sFractionNoZeros = sFraction.replace(rTrailingZeroes, '');
974
1003
  }
975
1004
  o = {
976
1005
  n: parseFloat(sValue),
977
- i: parseInt(sDecimal),
1006
+ i: parseInt(sInteger),
978
1007
  v: sFraction.length,
979
1008
  w: sFractionNoZeros.length,
980
- f: parseInt(sFraction),
981
- t: parseInt(sFractionNoZeros)
1009
+ f: sFraction === '' ? 0 : parseInt(sFraction),
1010
+ t: sFractionNoZeros === '' ? 0 : parseInt(sFractionNoZeros),
1011
+ c: iExponent
1012
+ };
1013
+ return {
1014
+ bMatch: fnOr(o),
1015
+ oOperands: o
982
1016
  };
983
- return fnOr(o);
984
1017
  };
985
1018
  }
986
1019
  });
1020
+ LocaleData.convertToDecimal = function (vValue) {
1021
+ var iIntegerLength, iExponent, iFractionLength, bNegative, iNewIntegerLength, aResult, sValue = String(vValue);
1022
+ if (!sValue.includes('e') && !sValue.includes('E')) {
1023
+ return sValue;
1024
+ }
1025
+ aResult = sValue.match(rNumberInScientificNotation);
1026
+ bNegative = aResult[1] === '-';
1027
+ sValue = aResult[2].replace('.', '');
1028
+ iIntegerLength = aResult[3] ? aResult[3].length : 0;
1029
+ iFractionLength = aResult[4] ? aResult[4].length : 0;
1030
+ iExponent = parseInt(aResult[5]);
1031
+ iNewIntegerLength = iIntegerLength + iExponent;
1032
+ if (iExponent > 0) {
1033
+ sValue = iExponent < iFractionLength ? sValue.slice(0, iNewIntegerLength) + '.' + sValue.slice(iNewIntegerLength) : sValue = sValue.padEnd(iNewIntegerLength, '0');
1034
+ } else {
1035
+ sValue = -iExponent < iIntegerLength ? sValue = sValue.slice(0, iNewIntegerLength) + '.' + sValue.slice(iNewIntegerLength) : sValue = '0.' + sValue.padStart(iFractionLength - iExponent, '0');
1036
+ }
1037
+ if (bNegative) {
1038
+ sValue = '-' + sValue;
1039
+ }
1040
+ return sValue;
1041
+ };
987
1042
  var mCLDRSymbolGroups = {
988
1043
  'Era': {
989
1044
  field: 'era',
@@ -1212,12 +1267,13 @@ var mCLDRSymbols = {
1212
1267
  numericCeiling: 100
1213
1268
  }
1214
1269
  };
1215
- var M_ISO639_OLD_TO_NEW = {
1216
- 'iw': 'he',
1217
- 'ji': 'yi'
1218
- };
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$');
1219
1275
  var M_SUPPORTED_LOCALES = function () {
1220
- var LOCALES = Locale._cldrLocales, result = {}, i;
1276
+ var LOCALES = _cldrLocales, result = {}, i;
1221
1277
  if (LOCALES) {
1222
1278
  for (i = 0; i < LOCALES.length; i++) {
1223
1279
  result[LOCALES[i]] = true;
@@ -1267,7 +1323,7 @@ function getData(oLocale) {
1267
1323
  obj[name] = fallbackValue;
1268
1324
  } else if (value === null) {
1269
1325
  delete obj[name];
1270
- } else if (typeof value === 'object' && typeof fallbackValue === 'object') {
1326
+ } else if (typeof value === 'object' && typeof fallbackValue === 'object' && !Array.isArray(value)) {
1271
1327
  merge(value, fallbackValue);
1272
1328
  }
1273
1329
  }
@@ -1286,7 +1342,7 @@ function getData(oLocale) {
1286
1342
  }
1287
1343
  return mLocaleDatas[sId];
1288
1344
  }
1289
- sLanguage = sLanguage && M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
1345
+ sLanguage = sLanguage && Localization.getModernLanguage(sLanguage) || sLanguage;
1290
1346
  if (sLanguage === 'no') {
1291
1347
  sLanguage = 'nb';
1292
1348
  }
@@ -1347,9 +1403,25 @@ var CustomLocaleData = LocaleData.extend('sap.ui.core.CustomLocaleData', {
1347
1403
  var mData = this._getDeep(this.mData, arguments);
1348
1404
  var mCustomData = this._getDeep(this.mCustomData, arguments);
1349
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;
1350
1420
  }
1351
1421
  });
1352
1422
  LocaleData.getInstance = function (oLocale) {
1423
+ oLocale = Locale._getCoreLocale(oLocale);
1353
1424
  return oLocale.hasPrivateUseSubtag('sapufmt') ? new CustomLocaleData(oLocale) : new LocaleData(oLocale);
1354
1425
  };
1426
+ LocaleData._cldrLocales = _cldrLocales;
1355
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;
@@ -0,0 +1,305 @@
1
+ import Configuration from '../Configuration.js';
2
+ import TimezoneUtil from '../format/TimezoneUtil.js';
3
+ var aAllParts = [
4
+ 'year',
5
+ 'month',
6
+ 'day',
7
+ 'hour',
8
+ 'minute',
9
+ 'second',
10
+ 'fractionalSecond'
11
+ ], rIsUTCString = /Z|GMT|:.*[\+|\-]|^([\+|\-]\d{2})?\d{4}(-\d{2}){0,2}$/, aWeekday = [
12
+ 'Sun',
13
+ 'Mon',
14
+ 'Tue',
15
+ 'Wed',
16
+ 'Thu',
17
+ 'Fri',
18
+ 'Sat'
19
+ ], aMonths = [
20
+ 'Jan',
21
+ 'Feb',
22
+ 'Mar',
23
+ 'Apr',
24
+ 'May',
25
+ 'Jun',
26
+ 'Jul',
27
+ 'Aug',
28
+ 'Sep',
29
+ 'Oct',
30
+ 'Nov',
31
+ 'Dec'
32
+ ], mWeekdayToDay = {
33
+ Sun: 0,
34
+ Mon: 1,
35
+ Tue: 2,
36
+ Wed: 3,
37
+ Thu: 4,
38
+ Fri: 5,
39
+ Sat: 6
40
+ };
41
+ function addLeadingZeros(iValue, iLength) {
42
+ return (iValue < 0 ? '-' : '') + Math.abs(iValue).toString().padStart(iLength, '0');
43
+ }
44
+ function UI5Date(vDateParts, sTimezoneID) {
45
+ var oDateInstance = UI5Date._createDateInstance(vDateParts);
46
+ Object.defineProperties(this, {
47
+ sTimezoneID: { value: sTimezoneID },
48
+ oDate: {
49
+ value: oDateInstance,
50
+ writable: true
51
+ },
52
+ oDateParts: {
53
+ value: undefined,
54
+ writable: true
55
+ }
56
+ });
57
+ if (isNaN(oDateInstance)) {
58
+ return;
59
+ }
60
+ if (vDateParts.length > 1 || vDateParts.length === 1 && typeof vDateParts[0] === 'string' && !rIsUTCString.test(vDateParts[0])) {
61
+ this._setParts(aAllParts, [
62
+ oDateInstance.getFullYear(),
63
+ oDateInstance.getMonth(),
64
+ oDateInstance.getDate(),
65
+ oDateInstance.getHours(),
66
+ oDateInstance.getMinutes(),
67
+ oDateInstance.getSeconds(),
68
+ oDateInstance.getMilliseconds()
69
+ ]);
70
+ }
71
+ }
72
+ UI5Date.prototype = Object.create(Date.prototype, { constructor: { value: Date } });
73
+ UI5Date.prototype[Symbol.toStringTag] = 'Date';
74
+ UI5Date.prototype._getPart = function (sPart) {
75
+ var iResult;
76
+ if (isNaN(this.oDate)) {
77
+ return NaN;
78
+ }
79
+ this.oDateParts = this.oDateParts || TimezoneUtil._getParts(this.oDate, this.sTimezoneID);
80
+ if (sPart === 'weekday') {
81
+ return mWeekdayToDay[this.oDateParts.weekday];
82
+ }
83
+ iResult = parseInt(this.oDateParts[sPart]);
84
+ if (sPart === 'month') {
85
+ iResult -= 1;
86
+ } else if (sPart === 'year') {
87
+ if (this.oDateParts.era === 'B') {
88
+ iResult = 1 - iResult;
89
+ }
90
+ }
91
+ return iResult;
92
+ };
93
+ UI5Date.prototype._setParts = function (aParts, aValues) {
94
+ var i, oCurrentDateParts, oNewDateAsUTCTimestamp, iNewTimestamp, sPart, vValue, oDateParts = {}, iMaxLength = Math.min(aParts.length, aValues.length);
95
+ if (iMaxLength === 0) {
96
+ return this.setTime(NaN);
97
+ }
98
+ for (i = 0; i < iMaxLength; i += 1) {
99
+ vValue = parseInt(+aValues[i]);
100
+ sPart = aParts[i];
101
+ if (isNaN(vValue)) {
102
+ return this.setTime(NaN);
103
+ }
104
+ if (sPart === 'month') {
105
+ vValue += 1;
106
+ } else if (sPart === 'year') {
107
+ if (vValue <= 0) {
108
+ vValue = 1 - vValue;
109
+ oDateParts.era = 'B';
110
+ } else {
111
+ oDateParts.era = 'A';
112
+ }
113
+ }
114
+ oDateParts[sPart] = vValue.toString();
115
+ }
116
+ if (this.oDateParts) {
117
+ oCurrentDateParts = this.oDateParts;
118
+ } else if (isNaN(this.oDate)) {
119
+ oCurrentDateParts = {
120
+ day: '1',
121
+ fractionalSecond: '0',
122
+ hour: '0',
123
+ minute: '0',
124
+ month: '1',
125
+ second: '0'
126
+ };
127
+ } else {
128
+ oCurrentDateParts = TimezoneUtil._getParts(this.oDate, this.sTimezoneID);
129
+ }
130
+ oDateParts = Object.assign({}, oCurrentDateParts, oDateParts);
131
+ oNewDateAsUTCTimestamp = TimezoneUtil._getDateFromParts(oDateParts);
132
+ if (isNaN(oNewDateAsUTCTimestamp)) {
133
+ return this.setTime(NaN);
134
+ }
135
+ iNewTimestamp = oNewDateAsUTCTimestamp.getTime() + TimezoneUtil.calculateOffset(oNewDateAsUTCTimestamp, this.sTimezoneID) * 1000;
136
+ return this.setTime(iNewTimestamp);
137
+ };
138
+ UI5Date.prototype.clone = function () {
139
+ return UI5Date.getInstance(this);
140
+ };
141
+ UI5Date.prototype.getDate = function () {
142
+ return this._getPart('day');
143
+ };
144
+ UI5Date.prototype.getDay = function () {
145
+ return this._getPart('weekday');
146
+ };
147
+ UI5Date.prototype.getFullYear = function () {
148
+ return this._getPart('year');
149
+ };
150
+ UI5Date.prototype.getHours = function () {
151
+ return this._getPart('hour');
152
+ };
153
+ UI5Date.prototype.getMilliseconds = function () {
154
+ return this._getPart('fractionalSecond');
155
+ };
156
+ UI5Date.prototype.getMinutes = function () {
157
+ return this._getPart('minute');
158
+ };
159
+ UI5Date.prototype.getMonth = function () {
160
+ return this._getPart('month');
161
+ };
162
+ UI5Date.prototype.getSeconds = function () {
163
+ return this._getPart('second');
164
+ };
165
+ UI5Date.prototype.getTimezoneOffset = function () {
166
+ return TimezoneUtil.calculateOffset(this.oDate, this.sTimezoneID) / 60;
167
+ };
168
+ UI5Date.prototype.getYear = function () {
169
+ return this._getPart('year') - 1900;
170
+ };
171
+ UI5Date.prototype.setDate = function (iDay) {
172
+ return this._setParts(['day'], arguments);
173
+ };
174
+ UI5Date.prototype.setFullYear = function (iYear, iMonth, iDay) {
175
+ return this._setParts([
176
+ 'year',
177
+ 'month',
178
+ 'day'
179
+ ], arguments);
180
+ };
181
+ UI5Date.prototype.setHours = function (iHours, iMinutes, iSeconds, iMilliseconds) {
182
+ return this._setParts([
183
+ 'hour',
184
+ 'minute',
185
+ 'second',
186
+ 'fractionalSecond'
187
+ ], arguments);
188
+ };
189
+ UI5Date.prototype.setMilliseconds = function (iMilliseconds) {
190
+ return this._setParts(['fractionalSecond'], arguments);
191
+ };
192
+ UI5Date.prototype.setMinutes = function (iMinutes, iSeconds, iMilliseconds) {
193
+ return this._setParts([
194
+ 'minute',
195
+ 'second',
196
+ 'fractionalSecond'
197
+ ], arguments);
198
+ };
199
+ UI5Date.prototype.setMonth = function (iMonth, iDay) {
200
+ return this._setParts([
201
+ 'month',
202
+ 'day'
203
+ ], arguments);
204
+ };
205
+ UI5Date.prototype.setSeconds = function (iSeconds, iMilliseconds) {
206
+ return this._setParts([
207
+ 'second',
208
+ 'fractionalSecond'
209
+ ], arguments);
210
+ };
211
+ UI5Date.prototype.setTime = function (iTime) {
212
+ this.oDateParts = undefined;
213
+ return this.oDate.setTime(iTime);
214
+ };
215
+ UI5Date.prototype.setYear = function (iYear) {
216
+ return this._setParts(['year'], [parseInt(iYear) + 1900]);
217
+ };
218
+ UI5Date.prototype.toDateString = function () {
219
+ if (isNaN(this.oDate)) {
220
+ return this.oDate.toDateString();
221
+ }
222
+ return aWeekday[this.getDay()] + ' ' + aMonths[this.getMonth()] + ' ' + addLeadingZeros(this.getDate(), 2) + ' ' + addLeadingZeros(this.getFullYear(), 4);
223
+ };
224
+ UI5Date.prototype.toString = function () {
225
+ if (isNaN(this.oDate)) {
226
+ return this.oDate.toString();
227
+ }
228
+ return this.toDateString() + ' ' + this.toTimeString();
229
+ };
230
+ UI5Date.prototype.toTimeString = function () {
231
+ var iHours, iMinutes, sSign, iTimeZoneOffset;
232
+ if (isNaN(this.oDate)) {
233
+ return this.oDate.toTimeString();
234
+ }
235
+ iTimeZoneOffset = this.getTimezoneOffset();
236
+ sSign = iTimeZoneOffset > 0 ? '-' : '+';
237
+ iHours = Math.floor(Math.abs(iTimeZoneOffset) / 60);
238
+ iMinutes = Math.abs(iTimeZoneOffset) % 60;
239
+ return addLeadingZeros(this.getHours(), 2) + ':' + addLeadingZeros(this.getMinutes(), 2) + ':' + addLeadingZeros(this.getSeconds(), 2) + ' GMT' + sSign + addLeadingZeros(iHours, 2) + addLeadingZeros(iMinutes, 2);
240
+ };
241
+ [
242
+ 'getTime',
243
+ 'getUTCDate',
244
+ 'getUTCDay',
245
+ 'getUTCFullYear',
246
+ 'getUTCHours',
247
+ 'getUTCMilliseconds',
248
+ 'getUTCMinutes',
249
+ 'getUTCMonth',
250
+ 'getUTCSeconds',
251
+ 'toGMTString',
252
+ 'toISOString',
253
+ 'toJSON',
254
+ 'toUTCString',
255
+ 'valueOf'
256
+ ].forEach(function (sMethod) {
257
+ UI5Date.prototype[sMethod] = function () {
258
+ return this.oDate[sMethod].apply(this.oDate, arguments);
259
+ };
260
+ });
261
+ [
262
+ 'toLocaleDateString',
263
+ 'toLocaleString',
264
+ 'toLocaleTimeString'
265
+ ].forEach(function (sMethod) {
266
+ UI5Date.prototype[sMethod] = function (sLocale, oOptions) {
267
+ return this.oDate[sMethod](sLocale || Configuration.getLanguageTag(), Object.assign({ timeZone: this.sTimezoneID }, oOptions));
268
+ };
269
+ });
270
+ [
271
+ 'setUTCDate',
272
+ 'setUTCFullYear',
273
+ 'setUTCHours',
274
+ 'setUTCMilliseconds',
275
+ 'setUTCMinutes',
276
+ 'setUTCMonth',
277
+ 'setUTCSeconds'
278
+ ].forEach(function (sMethod) {
279
+ UI5Date.prototype[sMethod] = function () {
280
+ this.oDateParts = undefined;
281
+ return this.oDate[sMethod].apply(this.oDate, arguments);
282
+ };
283
+ });
284
+ UI5Date._createDateInstance = function (vParts) {
285
+ if (vParts[0] instanceof Date) {
286
+ vParts[0] = vParts[0].valueOf();
287
+ }
288
+ return new (Function.prototype.bind.apply(Date, [].concat.apply([null], vParts)))();
289
+ };
290
+ UI5Date.getInstance = function () {
291
+ var sTimezone = Configuration.getTimezone();
292
+ if (sTimezone !== TimezoneUtil.getLocalTimezone()) {
293
+ return new UI5Date(arguments, sTimezone);
294
+ }
295
+ return UI5Date._createDateInstance(arguments);
296
+ };
297
+ UI5Date.checkDate = function (oDate) {
298
+ if (isNaN(oDate.getTime())) {
299
+ throw new Error('The given Date is not valid');
300
+ }
301
+ if (!(oDate instanceof UI5Date) && Configuration.getTimezone() !== TimezoneUtil.getLocalTimezone()) {
302
+ throw new Error('Configured time zone requires the parameter \'oDate\' to be an instance of' + ' sap.ui.core.date.UI5Date');
303
+ }
304
+ };
305
+ export default UI5Date;