@ui5/webcomponents-localization 0.0.0-b6f02e4b3 → 0.0.0-b93bc8b37
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/.eslintignore +1 -1
- package/.npsrc.json +3 -0
- package/CHANGELOG.md +248 -0
- package/README.md +5 -6
- package/{src/Assets-static.js → dist/Assets-static.d.ts} +0 -1
- package/dist/Assets-static.js +1 -0
- package/dist/Assets-static.js.map +1 -0
- package/dist/Assets.d.ts +1 -0
- package/dist/Assets.js +1 -0
- package/dist/Assets.js.map +1 -0
- package/dist/DateFormat.d.ts +6 -0
- package/dist/DateFormat.js +6 -2
- package/dist/DateFormat.js.map +1 -0
- package/dist/LocaleData.d.ts +6 -0
- package/dist/LocaleData.js +6 -2
- package/dist/LocaleData.js.map +1 -0
- package/dist/dates/CalendarDate.d.ts +43 -0
- package/dist/dates/CalendarDate.js +171 -207
- package/dist/dates/CalendarDate.js.map +1 -0
- package/dist/dates/ExtremeDates.d.ts +5 -0
- package/dist/dates/ExtremeDates.js +25 -35
- package/dist/dates/ExtremeDates.js.map +1 -0
- package/dist/dates/UI5Date.d.ts +6 -0
- package/dist/dates/UI5Date.js +7 -0
- package/dist/dates/UI5Date.js.map +1 -0
- package/dist/dates/UniversalDate.d.ts +47 -0
- package/dist/dates/UniversalDate.js +5 -0
- package/dist/dates/UniversalDate.js.map +1 -0
- package/dist/dates/calculateWeekNumber.d.ts +5 -0
- package/dist/dates/calculateWeekNumber.js +42 -48
- package/dist/dates/calculateWeekNumber.js.map +1 -0
- package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
- package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
- package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
- package/dist/dates/getDaysInMonth.d.ts +3 -0
- package/dist/dates/getDaysInMonth.js +10 -0
- package/dist/dates/getDaysInMonth.js.map +1 -0
- package/dist/dates/getRoundedTimestamp.d.ts +7 -0
- package/dist/dates/getRoundedTimestamp.js +10 -9
- package/dist/dates/getRoundedTimestamp.js.map +1 -0
- package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
- package/dist/dates/getTodayUTCTimestamp.js +3 -3
- package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
- package/dist/dates/modifyDateBy.d.ts +13 -0
- package/dist/dates/modifyDateBy.js +27 -29
- package/dist/dates/modifyDateBy.js.map +1 -0
- package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
- package/dist/dates/transformDateToSecondaryType.js +18 -0
- package/dist/dates/transformDateToSecondaryType.js.map +1 -0
- package/dist/features/calendar/Buddhist.js +1 -0
- package/dist/features/calendar/Buddhist.js.map +1 -0
- package/dist/features/calendar/Gregorian.js +1 -0
- package/dist/features/calendar/Gregorian.js.map +1 -0
- package/dist/features/calendar/Islamic.js +1 -0
- package/dist/features/calendar/Islamic.js.map +1 -0
- package/dist/features/calendar/Japanese.js +1 -0
- package/dist/features/calendar/Japanese.js.map +1 -0
- package/dist/features/calendar/Persian.js +1 -0
- package/dist/features/calendar/Persian.js.map +1 -0
- package/dist/generated/assets/cldr/ar.json +2816 -5906
- package/dist/generated/assets/cldr/ar_EG.json +2816 -5906
- package/dist/generated/assets/cldr/ar_SA.json +2815 -5906
- package/dist/generated/assets/cldr/bg.json +2733 -4979
- package/dist/generated/assets/cldr/ca.json +2680 -4996
- package/dist/generated/assets/cldr/cs.json +2716 -5498
- package/dist/generated/assets/cldr/cy.json +2797 -5884
- package/dist/generated/assets/cldr/da.json +2597 -4888
- package/dist/generated/assets/cldr/de.json +2614 -4916
- package/dist/generated/assets/cldr/de_AT.json +2614 -4917
- package/dist/generated/assets/cldr/de_CH.json +2614 -4915
- package/dist/generated/assets/cldr/el.json +2595 -4883
- package/dist/generated/assets/cldr/el_CY.json +2595 -4883
- package/dist/generated/assets/cldr/en.json +2583 -4971
- package/dist/generated/assets/cldr/en_AU.json +2592 -4962
- package/dist/generated/assets/cldr/en_GB.json +2584 -4971
- package/dist/generated/assets/cldr/en_HK.json +2593 -4977
- package/dist/generated/assets/cldr/en_IE.json +2584 -4971
- package/dist/generated/assets/cldr/en_IN.json +2588 -4972
- package/dist/generated/assets/cldr/en_NZ.json +2584 -4971
- package/dist/generated/assets/cldr/en_PG.json +2584 -4972
- package/dist/generated/assets/cldr/en_SG.json +2588 -4973
- package/dist/generated/assets/cldr/en_ZA.json +2584 -4972
- package/dist/generated/assets/cldr/es.json +2640 -4912
- package/dist/generated/assets/cldr/es_AR.json +2645 -4914
- package/dist/generated/assets/cldr/es_BO.json +2645 -4913
- package/dist/generated/assets/cldr/es_CL.json +2645 -4914
- package/dist/generated/assets/cldr/es_CO.json +2644 -4913
- package/dist/generated/assets/cldr/es_MX.json +2645 -4915
- package/dist/generated/assets/cldr/es_PE.json +2645 -4913
- package/dist/generated/assets/cldr/es_UY.json +2645 -4915
- package/dist/generated/assets/cldr/es_VE.json +2645 -4914
- package/dist/generated/assets/cldr/et.json +2599 -4967
- package/dist/generated/assets/cldr/fa.json +2618 -4883
- package/dist/generated/assets/cldr/fi.json +2726 -5008
- package/dist/generated/assets/cldr/fr.json +2590 -4979
- package/dist/generated/assets/cldr/fr_BE.json +2590 -4979
- package/dist/generated/assets/cldr/fr_CA.json +2605 -4973
- package/dist/generated/assets/cldr/fr_CH.json +2607 -4997
- package/dist/generated/assets/cldr/fr_LU.json +2590 -4979
- package/dist/generated/assets/cldr/he.json +2711 -5378
- package/dist/generated/assets/cldr/hi.json +2602 -4829
- package/dist/generated/assets/cldr/hr.json +2652 -4919
- package/dist/generated/assets/cldr/hu.json +2598 -4856
- package/dist/generated/assets/cldr/id.json +2544 -4658
- package/dist/generated/assets/cldr/it.json +2590 -4950
- package/dist/generated/assets/cldr/it_CH.json +2590 -4950
- package/dist/generated/assets/cldr/ja.json +2663 -4830
- package/dist/generated/assets/cldr/kk.json +2589 -4725
- package/dist/generated/assets/cldr/ko.json +2641 -4738
- package/dist/generated/assets/cldr/lt.json +2720 -5481
- package/dist/generated/assets/cldr/lv.json +2644 -5112
- package/dist/generated/assets/cldr/ms.json +2538 -4515
- package/dist/generated/assets/cldr/nb.json +2621 -4977
- package/dist/generated/assets/cldr/nl.json +2601 -4884
- package/dist/generated/assets/cldr/nl_BE.json +2601 -4884
- package/dist/generated/assets/cldr/pl.json +2723 -5176
- package/dist/generated/assets/cldr/pt.json +2607 -4805
- package/dist/generated/assets/cldr/pt_PT.json +2658 -4940
- package/dist/generated/assets/cldr/ro.json +2645 -5090
- package/dist/generated/assets/cldr/ru.json +2704 -5407
- package/dist/generated/assets/cldr/ru_UA.json +2704 -5407
- package/dist/generated/assets/cldr/sk.json +2726 -5370
- package/dist/generated/assets/cldr/sl.json +2688 -5340
- package/dist/generated/assets/cldr/sr.json +2663 -5126
- package/dist/generated/assets/cldr/sr_Latn.json +2666 -5127
- package/dist/generated/assets/cldr/sv.json +2631 -5011
- package/dist/generated/assets/cldr/th.json +2635 -4797
- package/dist/generated/assets/cldr/tr.json +2612 -4979
- package/dist/generated/assets/cldr/uk.json +2684 -5353
- package/dist/generated/assets/cldr/vi.json +2555 -4673
- package/dist/generated/assets/cldr/zh_CN.json +2555 -4632
- package/dist/generated/assets/cldr/zh_HK.json +2563 -4640
- package/dist/generated/assets/cldr/zh_SG.json +2562 -4640
- package/dist/generated/assets/cldr/zh_TW.json +2587 -4728
- package/dist/getCachedLocaleDataInstance.d.ts +4 -0
- package/dist/getCachedLocaleDataInstance.js +6 -9
- package/dist/getCachedLocaleDataInstance.js.map +1 -0
- package/dist/locale/getLocaleData.d.ts +11 -0
- package/dist/locale/getLocaleData.js +13 -17
- package/dist/locale/getLocaleData.js.map +1 -0
- package/dist/sap/base/Log.js +28 -29
- package/dist/sap/base/assert.js +5 -6
- package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
- package/dist/sap/base/util/LoaderExtensions.js +9 -12
- package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
- package/dist/sap/ui/core/Configuration.d.ts +17 -0
- package/dist/sap/ui/core/Configuration.js +21 -0
- package/dist/sap/ui/core/Configuration.js.map +1 -0
- package/dist/sap/ui/core/Core.d.ts +26 -0
- package/dist/sap/ui/core/Core.js +7 -34
- package/dist/sap/ui/core/Core.js.map +1 -0
- package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
- package/dist/sap/ui/core/FormatSettings.js +14 -0
- package/dist/sap/ui/core/FormatSettings.js.map +1 -0
- package/dist/sap/ui/core/Locale.js +3 -0
- package/dist/sap/ui/core/LocaleData.js +151 -22
- 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/UI5Date.js +305 -0
- package/dist/sap/ui/core/date/UniversalDate.js +79 -27
- package/dist/sap/ui/core/format/DateFormat.js +463 -349
- package/dist/sap/ui/core/format/TimezoneUtil.js +19 -13
- package/{package-scripts.js → package-scripts.cjs} +7 -5
- package/package.json +7 -5
- package/tsconfig.json +14 -0
- package/used-modules.txt +4 -1
- package/src/Assets.js +0 -2
- package/src/DateFormat.js +0 -3
- package/src/LocaleData.js +0 -3
- package/src/dates/CalendarDate.js +0 -229
- package/src/dates/ExtremeDates.js +0 -39
- package/src/dates/calculateWeekNumber.js +0 -51
- package/src/dates/getRoundedTimestamp.js +0 -14
- package/src/dates/getTodayUTCTimestamp.js +0 -9
- package/src/dates/modifyDateBy.js +0 -42
- package/src/getCachedLocaleDataInstance.js +0 -13
- package/src/locale/getLocaleData.js +0 -27
- package/src/sap/base/util/LoaderExtensions.js +0 -17
- package/src/sap/ui/core/Core.js +0 -40
- /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
- /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
- /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
- /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
- /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -5,6 +5,17 @@ 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';
|
9
|
+
var rEIgnoreCase = /e/i, mLegacyUnit2CurrentUnit = {
|
10
|
+
'acceleration-meter-per-second-squared': 'acceleration-meter-per-square-second',
|
11
|
+
'concentr-milligram-per-deciliter': 'concentr-milligram-ofglucose-per-deciliter',
|
12
|
+
'concentr-part-per-million': 'concentr-permillion',
|
13
|
+
'consumption-liter-per-100kilometers': 'consumption-liter-per-100-kilometer',
|
14
|
+
'pressure-millimeter-of-mercury': 'pressure-millimeter-ofhg',
|
15
|
+
'pressure-pound-per-square-inch': 'pressure-pound-force-per-square-inch',
|
16
|
+
'pressure-inch-hg': 'pressure-inch-ofhg',
|
17
|
+
'torque-pound-foot': 'torque-pound-force-foot'
|
18
|
+
}, rNumberInScientificNotation = /^([+-]?)((\d+)(?:\.(\d+))?)[eE]([+-]?\d+)$/, rTrailingZeroes = /0+$/;
|
8
19
|
var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
9
20
|
constructor: function (oLocale) {
|
10
21
|
this.oLocale = oLocale;
|
@@ -97,6 +108,56 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
97
108
|
assert(sStyle == 'short' || sStyle == 'medium' || sStyle == 'long' || sStyle == 'full', 'sStyle must be short, medium, long or full');
|
98
109
|
return this._get(getCLDRCalendarName(sCalendarType), 'dateFormats', sStyle);
|
99
110
|
},
|
111
|
+
getFlexibleDayPeriods: function (sWidth, sCalendarType) {
|
112
|
+
return this._get(getCLDRCalendarName(sCalendarType), 'flexibleDayPeriods', 'format', sWidth);
|
113
|
+
},
|
114
|
+
getFlexibleDayPeriodsStandAlone: function (sWidth, sCalendarType) {
|
115
|
+
return this._get(getCLDRCalendarName(sCalendarType), 'flexibleDayPeriods', 'stand-alone', sWidth);
|
116
|
+
},
|
117
|
+
getFlexibleDayPeriodOfTime: function (iHour, iMinute) {
|
118
|
+
var iAbsoluteMinutes, oDayPeriodRules, sPeriodMatch;
|
119
|
+
iAbsoluteMinutes = (iHour * 60 + iMinute) % 1440;
|
120
|
+
oDayPeriodRules = this._get('dayPeriodRules');
|
121
|
+
function parseToAbsoluteMinutes(sValue) {
|
122
|
+
var aSplit = sValue.split(':'), sHour = aSplit[0], sMinute = aSplit[1];
|
123
|
+
return parseInt(sHour) * 60 + parseInt(sMinute);
|
124
|
+
}
|
125
|
+
sPeriodMatch = Object.keys(oDayPeriodRules).find(function (sDayPeriodRule) {
|
126
|
+
var oDayPeriodRule = oDayPeriodRules[sDayPeriodRule];
|
127
|
+
return oDayPeriodRule['_at'] && parseToAbsoluteMinutes(oDayPeriodRule['_at']) === iAbsoluteMinutes;
|
128
|
+
});
|
129
|
+
if (sPeriodMatch) {
|
130
|
+
return sPeriodMatch;
|
131
|
+
}
|
132
|
+
return Object.keys(oDayPeriodRules).find(function (sDayPeriodRule) {
|
133
|
+
var iEndValue, aIntervals, iStartValue, oDayPeriodRule = oDayPeriodRules[sDayPeriodRule];
|
134
|
+
if (oDayPeriodRule['_at']) {
|
135
|
+
return false;
|
136
|
+
}
|
137
|
+
iStartValue = parseToAbsoluteMinutes(oDayPeriodRule['_from']);
|
138
|
+
iEndValue = parseToAbsoluteMinutes(oDayPeriodRule['_before']);
|
139
|
+
if (iStartValue > iEndValue) {
|
140
|
+
aIntervals = [
|
141
|
+
{
|
142
|
+
start: iStartValue,
|
143
|
+
end: 1440
|
144
|
+
},
|
145
|
+
{
|
146
|
+
start: 0,
|
147
|
+
end: iEndValue
|
148
|
+
}
|
149
|
+
];
|
150
|
+
} else {
|
151
|
+
aIntervals = [{
|
152
|
+
start: iStartValue,
|
153
|
+
end: iEndValue
|
154
|
+
}];
|
155
|
+
}
|
156
|
+
return aIntervals.some(function (oInterval) {
|
157
|
+
return oInterval.start <= iAbsoluteMinutes && oInterval.end > iAbsoluteMinutes;
|
158
|
+
});
|
159
|
+
});
|
160
|
+
},
|
100
161
|
getTimePattern: function (sStyle, sCalendarType) {
|
101
162
|
assert(sStyle == 'short' || sStyle == 'medium' || sStyle == 'long' || sStyle == 'full', 'sStyle must be short, medium, long or full');
|
102
163
|
return this._get(getCLDRCalendarName(sCalendarType), 'timeFormats', sStyle);
|
@@ -125,6 +186,10 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
125
186
|
this._appendItems(aPatterns, aMissingTokens);
|
126
187
|
return aPatterns[0];
|
127
188
|
},
|
189
|
+
getTimezoneTranslations: function () {
|
190
|
+
this.mTimezoneTranslations = this.mTimezoneTranslations || _resolveTimezoneTranslationStructure(this._get('timezoneNames'));
|
191
|
+
return Object.assign({}, this.mTimezoneTranslations);
|
192
|
+
},
|
128
193
|
getCustomDateTimePattern: function (sSkeleton, sCalendarType) {
|
129
194
|
var oAvailableFormats = this._get(getCLDRCalendarName(sCalendarType), 'dateTimeFormats', 'availableFormats');
|
130
195
|
return this._getFormatPattern(sSkeleton, oAvailableFormats, sCalendarType);
|
@@ -587,11 +652,14 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
587
652
|
oTimeEntry = oScale[sEntry];
|
588
653
|
iSign = sEntry.substr(18) === 'past' ? -1 : 1;
|
589
654
|
aPluralCategories.forEach(function (sKey) {
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
655
|
+
var sPattern = oTimeEntry['relativeTimePattern-count-' + sKey];
|
656
|
+
if (sPattern) {
|
657
|
+
aPatterns.push({
|
658
|
+
scale: sScale,
|
659
|
+
sign: iSign,
|
660
|
+
pattern: sPattern
|
661
|
+
});
|
662
|
+
}
|
595
663
|
});
|
596
664
|
}
|
597
665
|
}
|
@@ -714,7 +782,11 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
714
782
|
return this.getUnitFormat(sUnit);
|
715
783
|
},
|
716
784
|
getUnitFormat: function (sUnit) {
|
717
|
-
|
785
|
+
var oResult = this._get('units', 'short', sUnit);
|
786
|
+
if (!oResult && mLegacyUnit2CurrentUnit[sUnit]) {
|
787
|
+
oResult = this._get('units', 'short', mLegacyUnit2CurrentUnit[sUnit]);
|
788
|
+
}
|
789
|
+
return oResult;
|
718
790
|
},
|
719
791
|
getUnitFormats: function () {
|
720
792
|
return this._getMerged('units', 'short');
|
@@ -743,10 +815,10 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
743
815
|
return oMessageBundle.getText(sKey, iWeekNumber);
|
744
816
|
},
|
745
817
|
firstDayStartsFirstWeek: function () {
|
746
|
-
return this.
|
818
|
+
return this.oLocale.getLanguage() === 'en' && this.oLocale.getRegion() === 'US';
|
747
819
|
},
|
748
820
|
getPreferredCalendarType: function () {
|
749
|
-
var
|
821
|
+
var sCalendarName, sType, i, aCalendars = this._get('calendarPreference') || [];
|
750
822
|
for (i = 0; i < aCalendars.length; i++) {
|
751
823
|
sCalendarName = aCalendars[i].split('-')[0];
|
752
824
|
for (sType in CalendarType) {
|
@@ -779,14 +851,14 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
779
851
|
fnTest = this._parsePluralRule(oPlurals[sCategory]);
|
780
852
|
this._pluralTest[sCategory] = fnTest;
|
781
853
|
}
|
782
|
-
if (fnTest(sNumber)) {
|
854
|
+
if (fnTest(sNumber).bMatch) {
|
783
855
|
return sCategory;
|
784
856
|
}
|
785
857
|
}
|
786
858
|
return 'other';
|
787
859
|
},
|
788
860
|
_parsePluralRule: function (sRule) {
|
789
|
-
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 = ',';
|
861
|
+
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 = ',';
|
790
862
|
var i = 0, aTokens;
|
791
863
|
aTokens = sRule.split(' ');
|
792
864
|
function accept(sToken) {
|
@@ -880,6 +952,14 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
880
952
|
return function (o) {
|
881
953
|
return o.w;
|
882
954
|
};
|
955
|
+
} else if (accept(OPD_C)) {
|
956
|
+
return function (o) {
|
957
|
+
return o.c;
|
958
|
+
};
|
959
|
+
} else if (accept(OPD_E)) {
|
960
|
+
return function (o) {
|
961
|
+
return o.c;
|
962
|
+
};
|
883
963
|
} else {
|
884
964
|
throw new Error('Unknown operand: ' + consume());
|
885
965
|
}
|
@@ -907,28 +987,57 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
907
987
|
throw new Error('Not completely parsed');
|
908
988
|
}
|
909
989
|
return function (sValue) {
|
910
|
-
var iDotPos
|
990
|
+
var iDotPos, iExponent, sFraction, sFractionNoZeros, sInteger, o, iExponentPos = sValue.search(rEIgnoreCase);
|
991
|
+
iExponent = iExponentPos < 0 ? 0 : parseInt(sValue.slice(iExponentPos + 1));
|
992
|
+
sValue = LocaleData.convertToDecimal(sValue);
|
993
|
+
iDotPos = sValue.indexOf('.');
|
911
994
|
if (iDotPos === -1) {
|
912
|
-
|
995
|
+
sInteger = sValue;
|
913
996
|
sFraction = '';
|
914
997
|
sFractionNoZeros = '';
|
915
998
|
} else {
|
916
|
-
|
917
|
-
sFraction = sValue.
|
918
|
-
sFractionNoZeros = sFraction.replace(
|
999
|
+
sInteger = sValue.slice(0, iDotPos);
|
1000
|
+
sFraction = sValue.slice(iDotPos + 1);
|
1001
|
+
sFractionNoZeros = sFraction.replace(rTrailingZeroes, '');
|
919
1002
|
}
|
920
1003
|
o = {
|
921
1004
|
n: parseFloat(sValue),
|
922
|
-
i: parseInt(
|
1005
|
+
i: parseInt(sInteger),
|
923
1006
|
v: sFraction.length,
|
924
1007
|
w: sFractionNoZeros.length,
|
925
|
-
f: parseInt(sFraction),
|
926
|
-
t: parseInt(sFractionNoZeros)
|
1008
|
+
f: sFraction === '' ? 0 : parseInt(sFraction),
|
1009
|
+
t: sFractionNoZeros === '' ? 0 : parseInt(sFractionNoZeros),
|
1010
|
+
c: iExponent
|
1011
|
+
};
|
1012
|
+
return {
|
1013
|
+
bMatch: fnOr(o),
|
1014
|
+
oOperands: o
|
927
1015
|
};
|
928
|
-
return fnOr(o);
|
929
1016
|
};
|
930
1017
|
}
|
931
1018
|
});
|
1019
|
+
LocaleData.convertToDecimal = function (vValue) {
|
1020
|
+
var iIntegerLength, iExponent, iFractionLength, bNegative, iNewIntegerLength, aResult, sValue = String(vValue);
|
1021
|
+
if (!sValue.includes('e') && !sValue.includes('E')) {
|
1022
|
+
return sValue;
|
1023
|
+
}
|
1024
|
+
aResult = sValue.match(rNumberInScientificNotation);
|
1025
|
+
bNegative = aResult[1] === '-';
|
1026
|
+
sValue = aResult[2].replace('.', '');
|
1027
|
+
iIntegerLength = aResult[3] ? aResult[3].length : 0;
|
1028
|
+
iFractionLength = aResult[4] ? aResult[4].length : 0;
|
1029
|
+
iExponent = parseInt(aResult[5]);
|
1030
|
+
iNewIntegerLength = iIntegerLength + iExponent;
|
1031
|
+
if (iExponent > 0) {
|
1032
|
+
sValue = iExponent < iFractionLength ? sValue.slice(0, iNewIntegerLength) + '.' + sValue.slice(iNewIntegerLength) : sValue = sValue.padEnd(iNewIntegerLength, '0');
|
1033
|
+
} else {
|
1034
|
+
sValue = -iExponent < iIntegerLength ? sValue = sValue.slice(0, iNewIntegerLength) + '.' + sValue.slice(iNewIntegerLength) : sValue = '0.' + sValue.padStart(iFractionLength - iExponent, '0');
|
1035
|
+
}
|
1036
|
+
if (bNegative) {
|
1037
|
+
sValue = '-' + sValue;
|
1038
|
+
}
|
1039
|
+
return sValue;
|
1040
|
+
};
|
932
1041
|
var mCLDRSymbolGroups = {
|
933
1042
|
'Era': {
|
934
1043
|
field: 'era',
|
@@ -1171,9 +1280,29 @@ var M_SUPPORTED_LOCALES = function () {
|
|
1171
1280
|
return result;
|
1172
1281
|
}();
|
1173
1282
|
var mLocaleDatas = {};
|
1283
|
+
function _resolveTimezoneTranslationStructure(oNode, sKey, oResult, aParentTranslations) {
|
1284
|
+
aParentTranslations = aParentTranslations ? aParentTranslations.slice() : [];
|
1285
|
+
oResult = oResult || {};
|
1286
|
+
sKey = sKey || '';
|
1287
|
+
Object.keys(oNode).forEach(function (sChildKey) {
|
1288
|
+
var vChildNode = oNode[sChildKey];
|
1289
|
+
if (typeof vChildNode === 'object') {
|
1290
|
+
var aParentTranslationForChild = aParentTranslations.slice();
|
1291
|
+
var sParent = vChildNode['_parent'];
|
1292
|
+
if (sParent) {
|
1293
|
+
aParentTranslationForChild.push(sParent);
|
1294
|
+
}
|
1295
|
+
_resolveTimezoneTranslationStructure(vChildNode, sKey + sChildKey + '/', oResult, aParentTranslationForChild);
|
1296
|
+
} else if (typeof vChildNode === 'string' && sChildKey !== '_parent') {
|
1297
|
+
var sParents = aParentTranslations.length ? aParentTranslations.join(', ') + ', ' : '';
|
1298
|
+
oResult[sKey + sChildKey] = sParents + vChildNode;
|
1299
|
+
}
|
1300
|
+
});
|
1301
|
+
return oResult;
|
1302
|
+
}
|
1174
1303
|
function getCLDRCalendarName(sCalendarType) {
|
1175
1304
|
if (!sCalendarType) {
|
1176
|
-
sCalendarType =
|
1305
|
+
sCalendarType = Configuration.getCalendarType();
|
1177
1306
|
}
|
1178
1307
|
return 'ca-' + sCalendarType.toLowerCase();
|
1179
1308
|
}
|
@@ -1192,7 +1321,7 @@ function getData(oLocale) {
|
|
1192
1321
|
obj[name] = fallbackValue;
|
1193
1322
|
} else if (value === null) {
|
1194
1323
|
delete obj[name];
|
1195
|
-
} else if (typeof value === 'object' && typeof fallbackValue === 'object') {
|
1324
|
+
} else if (typeof value === 'object' && typeof fallbackValue === 'object' && !Array.isArray(value)) {
|
1196
1325
|
merge(value, fallbackValue);
|
1197
1326
|
}
|
1198
1327
|
}
|
@@ -1248,7 +1377,7 @@ function getData(oLocale) {
|
|
1248
1377
|
var CustomLocaleData = LocaleData.extend('sap.ui.core.CustomLocaleData', {
|
1249
1378
|
constructor: function (oLocale) {
|
1250
1379
|
LocaleData.apply(this, arguments);
|
1251
|
-
this.mCustomData =
|
1380
|
+
this.mCustomData = Configuration.getFormatSettings().getCustomLocaleData();
|
1252
1381
|
},
|
1253
1382
|
_get: function () {
|
1254
1383
|
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;
|
@@ -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;
|