@ui5/webcomponents-localization 0.0.0-96e98c995 → 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.
- package/.eslintignore +1 -1
- package/.npsrc.json +3 -0
- package/CHANGELOG.md +316 -0
- package/dist/Assets-static.js.map +1 -1
- package/dist/Assets.js.map +1 -1
- package/dist/DateFormat.js.map +1 -1
- package/dist/LocaleData.js.map +1 -1
- package/dist/dates/CalendarDate.d.ts +7 -5
- package/dist/dates/CalendarDate.js +8 -7
- package/dist/dates/CalendarDate.js.map +1 -1
- package/dist/dates/ExtremeDates.d.ts +2 -2
- package/dist/dates/ExtremeDates.js.map +1 -1
- 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 +2 -1
- package/dist/dates/UniversalDate.js.map +1 -1
- package/dist/dates/calculateWeekNumber.d.ts +2 -1
- package/dist/dates/calculateWeekNumber.js.map +1 -1
- package/dist/dates/convertMonthNumbersToMonthNames.d.ts +1 -1
- package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -1
- package/dist/dates/getDaysInMonth.js.map +1 -1
- package/dist/dates/getRoundedTimestamp.js +1 -0
- package/dist/dates/getRoundedTimestamp.js.map +1 -1
- package/dist/dates/getTodayUTCTimestamp.d.ts +1 -1
- package/dist/dates/getTodayUTCTimestamp.js +2 -1
- package/dist/dates/getTodayUTCTimestamp.js.map +1 -1
- package/dist/dates/modifyDateBy.d.ts +2 -1
- package/dist/dates/modifyDateBy.js +34 -19
- package/dist/dates/modifyDateBy.js.map +1 -1
- package/dist/dates/transformDateToSecondaryType.d.ts +1 -1
- package/dist/dates/transformDateToSecondaryType.js +3 -2
- package/dist/dates/transformDateToSecondaryType.js.map +1 -1
- package/dist/features/calendar/Buddhist.js.map +1 -1
- package/dist/features/calendar/Gregorian.js.map +1 -1
- package/dist/features/calendar/Islamic.js.map +1 -1
- package/dist/features/calendar/Japanese.js.map +1 -1
- package/dist/features/calendar/Persian.js.map +1 -1
- package/dist/generated/assets/cldr/ar.json +5531 -6704
- package/dist/generated/assets/cldr/ar_EG.json +5531 -6704
- package/dist/generated/assets/cldr/ar_SA.json +5530 -6704
- package/dist/generated/assets/cldr/bg.json +4452 -5742
- package/dist/generated/assets/cldr/ca.json +4440 -5793
- package/dist/generated/assets/cldr/cs.json +4960 -6294
- package/dist/generated/assets/cldr/cy.json +5211 -6612
- package/dist/generated/assets/cldr/da.json +4308 -5651
- package/dist/generated/assets/cldr/de.json +4313 -5713
- package/dist/generated/assets/cldr/de_AT.json +4314 -5714
- package/dist/generated/assets/cldr/de_CH.json +4312 -5712
- package/dist/generated/assets/cldr/el.json +4281 -5579
- package/dist/generated/assets/cldr/el_CY.json +4281 -5579
- package/dist/generated/assets/cldr/en.json +4316 -5732
- package/dist/generated/assets/cldr/en_AU.json +4319 -5724
- package/dist/generated/assets/cldr/en_GB.json +4329 -5733
- package/dist/generated/assets/cldr/en_HK.json +4337 -5739
- package/dist/generated/assets/cldr/en_IE.json +4328 -5733
- package/dist/generated/assets/cldr/en_IN.json +4333 -5734
- package/dist/generated/assets/cldr/en_NZ.json +4328 -5733
- package/dist/generated/assets/cldr/en_PG.json +4329 -5734
- package/dist/generated/assets/cldr/en_SG.json +4333 -5735
- package/dist/generated/assets/cldr/en_ZA.json +4329 -5734
- package/dist/generated/assets/cldr/es.json +4331 -5641
- package/dist/generated/assets/cldr/es_AR.json +4334 -5643
- package/dist/generated/assets/cldr/es_BO.json +4333 -5642
- package/dist/generated/assets/cldr/es_CL.json +4334 -5643
- package/dist/generated/assets/cldr/es_CO.json +4333 -5642
- package/dist/generated/assets/cldr/es_MX.json +4335 -5644
- package/dist/generated/assets/cldr/es_PE.json +4333 -5642
- package/dist/generated/assets/cldr/es_UY.json +4335 -5644
- package/dist/generated/assets/cldr/es_VE.json +4334 -5643
- package/dist/generated/assets/cldr/et.json +4340 -5729
- package/dist/generated/assets/cldr/fa.json +4367 -5647
- package/dist/generated/assets/cldr/fi.json +4463 -5804
- package/dist/generated/assets/cldr/fr.json +4357 -5741
- package/dist/generated/assets/cldr/fr_BE.json +4357 -5741
- package/dist/generated/assets/cldr/fr_CA.json +4351 -5735
- package/dist/generated/assets/cldr/fr_CH.json +4375 -5759
- package/dist/generated/assets/cldr/fr_LU.json +4357 -5741
- package/dist/generated/assets/cldr/he.json +4869 -6175
- package/dist/generated/assets/cldr/hi.json +4295 -5558
- package/dist/generated/assets/cldr/hr.json +4583 -5681
- package/dist/generated/assets/cldr/hu.json +4364 -5686
- package/dist/generated/assets/cldr/id.json +4060 -5420
- package/dist/generated/assets/cldr/it.json +4299 -5712
- package/dist/generated/assets/cldr/it_CH.json +4299 -5712
- package/dist/generated/assets/cldr/ja.json +4211 -5626
- package/dist/generated/assets/cldr/kk.json +4339 -5487
- package/dist/generated/assets/cldr/ko.json +4189 -5534
- package/dist/generated/assets/cldr/lt.json +4850 -6243
- package/dist/generated/assets/cldr/lv.json +4587 -5874
- package/dist/generated/assets/cldr/ms.json +4021 -5245
- package/dist/generated/assets/cldr/nb.json +4335 -5740
- package/dist/generated/assets/cldr/nl.json +4294 -5613
- package/dist/generated/assets/cldr/nl_BE.json +4294 -5613
- package/dist/generated/assets/cldr/pl.json +4667 -5972
- package/dist/generated/assets/cldr/pt.json +4235 -5567
- package/dist/generated/assets/cldr/pt_PT.json +4372 -5702
- package/dist/generated/assets/cldr/ro.json +4563 -5852
- package/dist/generated/assets/cldr/ru.json +4909 -6169
- package/dist/generated/assets/cldr/ru_UA.json +4909 -6169
- package/dist/generated/assets/cldr/sk.json +4939 -6166
- package/dist/generated/assets/cldr/sl.json +4910 -6136
- package/dist/generated/assets/cldr/sr.json +4585 -5888
- package/dist/generated/assets/cldr/sr_Latn.json +4574 -5889
- package/dist/generated/assets/cldr/sv.json +4362 -5774
- package/dist/generated/assets/cldr/th.json +4214 -5627
- package/dist/generated/assets/cldr/tr.json +4400 -5809
- package/dist/generated/assets/cldr/uk.json +4858 -6115
- package/dist/generated/assets/cldr/vi.json +4070 -5435
- package/dist/generated/assets/cldr/zh_CN.json +4100 -5429
- package/dist/generated/assets/cldr/zh_HK.json +4108 -5437
- package/dist/generated/assets/cldr/zh_SG.json +4108 -5437
- package/dist/generated/assets/cldr/zh_TW.json +4131 -5525
- package/dist/getCachedLocaleDataInstance.js.map +1 -1
- package/dist/locale/getLocaleData.js.map +1 -1
- package/dist/sap/base/i18n/LanguageTag.js +35 -0
- package/dist/sap/base/i18n/Localization.d.ts +4 -0
- package/dist/sap/base/i18n/Localization.js +12 -0
- package/dist/sap/base/i18n/Localization.js.map +1 -0
- package/dist/sap/base/i18n/date/CalendarType.js +8 -0
- package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +30 -0
- package/dist/sap/base/i18n/date/TimezoneUtils.js +89 -0
- package/dist/sap/base/util/LoaderExtensions.js.map +1 -1
- package/dist/sap/ui/base/Metadata.js +20 -9
- package/dist/sap/ui/core/CalendarType.js +2 -8
- package/dist/sap/ui/core/Configuration.d.ts +1 -1
- package/dist/sap/ui/core/Configuration.js +2 -1
- package/dist/sap/ui/core/Configuration.js.map +1 -1
- package/dist/sap/ui/core/Core.d.ts +2 -2
- package/dist/sap/ui/core/Core.js.map +1 -1
- package/dist/sap/ui/core/FormatSettings.d.ts +1 -1
- package/dist/sap/ui/core/FormatSettings.js +2 -1
- package/dist/sap/ui/core/FormatSettings.js.map +1 -1
- package/dist/sap/ui/core/Locale.js +28 -125
- package/dist/sap/ui/core/LocaleData.js +107 -35
- package/dist/sap/ui/core/date/CalendarUtils.js +7 -18
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +2 -7
- package/dist/sap/ui/core/date/UI5Date.js +305 -0
- package/dist/sap/ui/core/date/UniversalDate.js +12 -22
- package/dist/sap/ui/core/format/DateFormat.js +385 -329
- package/dist/sap/ui/core/format/TimezoneUtil.js +2 -94
- package/{package-scripts.js → package-scripts.cjs} +2 -3
- package/package.json +7 -6
- package/tsconfig.json +1 -0
- package/used-modules.txt +5 -0
- package/src/Assets-static.ts +0 -2
- package/src/Assets.ts +0 -2
- package/src/DateFormat.ts +0 -8
- package/src/LocaleData.ts +0 -8
- package/src/dates/CalendarDate.ts +0 -232
- package/src/dates/ExtremeDates.ts +0 -40
- package/src/dates/UniversalDate.ts +0 -51
- package/src/dates/calculateWeekNumber.ts +0 -53
- package/src/dates/convertMonthNumbersToMonthNames.ts +0 -34
- package/src/dates/getDaysInMonth.ts +0 -11
- package/src/dates/getRoundedTimestamp.ts +0 -14
- package/src/dates/getTodayUTCTimestamp.ts +0 -10
- package/src/dates/modifyDateBy.ts +0 -42
- package/src/dates/transformDateToSecondaryType.ts +0 -21
- package/src/features/calendar/Buddhist.ts +0 -1
- package/src/features/calendar/Gregorian.ts +0 -1
- package/src/features/calendar/Islamic.ts +0 -1
- package/src/features/calendar/Japanese.ts +0 -1
- package/src/features/calendar/Persian.ts +0 -1
- package/src/getCachedLocaleDataInstance.ts +0 -15
- package/src/locale/getLocaleData.ts +0 -28
- package/src/sap/base/util/LoaderExtensions.ts +0 -17
- package/src/sap/ui/core/Configuration.ts +0 -22
- package/src/sap/ui/core/Core.ts +0 -15
- package/src/sap/ui/core/FormatSettings.ts +0 -15
- /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -1,15 +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 UniversalDate from '../date/UniversalDate.js';
|
5
10
|
import CalendarUtils from '../date/CalendarUtils.js';
|
6
11
|
import CalendarWeekNumbering from '../date/CalendarWeekNumbering.js';
|
12
|
+
import UI5Date from '../date/UI5Date.js';
|
13
|
+
import UniversalDate from '../date/UniversalDate.js';
|
7
14
|
import TimezoneUtil from './TimezoneUtil.js';
|
8
|
-
import deepEqual from '../../../base/util/deepEqual.js';
|
9
|
-
import formatMessage from '../../../base/strings/formatMessage.js';
|
10
|
-
import Log from '../../../base/Log.js';
|
11
|
-
import extend from '../../../base/util/extend.js';
|
12
|
-
import Configuration from '../Configuration.js';
|
13
15
|
var DateFormat = function () {
|
14
16
|
throw new Error();
|
15
17
|
};
|
@@ -231,21 +233,23 @@ DateFormat.getDateTimeInstance = function (oFormatOptions, oLocale) {
|
|
231
233
|
};
|
232
234
|
DateFormat.getDateTimeWithTimezoneInstance = function (oFormatOptions, oLocale) {
|
233
235
|
if (oFormatOptions && !(oFormatOptions instanceof Locale)) {
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
if (
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
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
|
+
}
|
243
247
|
}
|
248
|
+
oFormatOptions.showTimezone = sShowTimezone !== 'Hide';
|
244
249
|
}
|
245
|
-
|
246
|
-
}
|
250
|
+
}());
|
247
251
|
if (oFormatOptions.showDate === false && oFormatOptions.showTime === false && oFormatOptions.showTimezone === false) {
|
248
|
-
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.');
|
249
253
|
}
|
250
254
|
}
|
251
255
|
return this.createInstance(oFormatOptions, oLocale, DateFormat._getDateTimeWithTimezoneInfo(oFormatOptions || {}));
|
@@ -258,8 +262,9 @@ function createIntervalPatternWithNormalConnector(oFormat) {
|
|
258
262
|
sPattern = sPattern.replace(/[^\{\}01 ]/, '-');
|
259
263
|
return sPattern.replace(/\{(0|1)\}/g, oFormat.oFormatOptions.pattern);
|
260
264
|
}
|
261
|
-
DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo) {
|
262
|
-
var oFormat
|
265
|
+
DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo, bIsFallback) {
|
266
|
+
var aFallbackFormatOptions, oFormat, sPattern;
|
267
|
+
oFormat = Object.create(this.prototype);
|
263
268
|
if (oFormatOptions instanceof Locale) {
|
264
269
|
oLocale = oFormatOptions;
|
265
270
|
oFormatOptions = undefined;
|
@@ -297,13 +302,16 @@ DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo) {
|
|
297
302
|
}
|
298
303
|
}
|
299
304
|
if (oFormat.oFormatOptions.interval) {
|
305
|
+
var sSinglePattern, sDelimiter = oFormat.oFormatOptions.intervalDelimiter;
|
300
306
|
if (oFormat.oFormatOptions.format) {
|
301
307
|
oFormat.intervalPatterns = oFormat.oLocaleData.getCustomIntervalPattern(oFormat.oFormatOptions.format, null, oFormat.oFormatOptions.calendarType);
|
302
308
|
if (typeof oFormat.intervalPatterns === 'string') {
|
303
309
|
oFormat.intervalPatterns = [oFormat.intervalPatterns];
|
304
310
|
}
|
305
|
-
oFormat.
|
311
|
+
sSinglePattern = oFormat.oLocaleData.getCustomDateTimePattern(oFormat.oFormatOptions.format, oFormat.oFormatOptions.calendarType);
|
312
|
+
oFormat.intervalPatterns.push(sSinglePattern);
|
306
313
|
} else {
|
314
|
+
sSinglePattern = oFormat.oFormatOptions.pattern;
|
307
315
|
oFormat.intervalPatterns = [
|
308
316
|
oFormat.oLocaleData.getCombinedIntervalPattern(oFormat.oFormatOptions.pattern, oFormat.oFormatOptions.calendarType),
|
309
317
|
oFormat.oFormatOptions.pattern
|
@@ -311,31 +319,34 @@ DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo) {
|
|
311
319
|
}
|
312
320
|
var sCommonConnectorPattern = createIntervalPatternWithNormalConnector(oFormat);
|
313
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));
|
314
328
|
}
|
315
|
-
if (!
|
316
|
-
|
317
|
-
|
329
|
+
if (!bIsFallback) {
|
330
|
+
aFallbackFormatOptions = oInfo.aFallbackFormatOptions;
|
331
|
+
if (oInfo.bShortFallbackFormatOptions) {
|
332
|
+
sPattern = oInfo.getPattern(oFormat.oLocaleData, 'short');
|
333
|
+
aFallbackFormatOptions = aFallbackFormatOptions.concat(DateFormat._createFallbackOptionsWithoutDelimiter(sPattern));
|
318
334
|
}
|
319
|
-
var sLocale = oLocale.toString(), sCalendarType = oFormat.oFormatOptions.calendarType, sKey = sLocale + '-' + sCalendarType, sPattern, aFallbackFormatOptions;
|
320
335
|
if (oFormat.oFormatOptions.pattern && oInfo.bPatternFallbackWithoutDelimiter) {
|
321
|
-
|
322
|
-
}
|
323
|
-
if (oFormat.oFormatOptions.interval) {
|
324
|
-
sKey = sKey + '-' + 'interval';
|
336
|
+
aFallbackFormatOptions = DateFormat._createFallbackOptionsWithoutDelimiter(oFormat.oFormatOptions.pattern).concat(aFallbackFormatOptions);
|
325
337
|
}
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
338
|
+
aFallbackFormatOptions = aFallbackFormatOptions.reduce(function (aFallbacks, oOptions) {
|
339
|
+
var aKeys = Object.keys(oOptions), bDuplicate = aFallbacks.some(function (oOptions0) {
|
340
|
+
return Object.keys(oOptions0).length === aKeys.length && aKeys.every(function (sKey) {
|
341
|
+
return oOptions0[sKey] === oOptions[sKey];
|
342
|
+
});
|
343
|
+
});
|
344
|
+
if (!bDuplicate) {
|
345
|
+
aFallbacks.push(oOptions);
|
332
346
|
}
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
oFallbackFormats = DateFormat._createFallbackFormat(aFallbackFormatOptions, sCalendarType, oLocale, oInfo, oFormat.oFormatOptions);
|
337
|
-
}
|
338
|
-
oFormat.aFallbackFormats = oFallbackFormats;
|
347
|
+
return aFallbacks;
|
348
|
+
}, []);
|
349
|
+
oFormat.aFallbackFormats = DateFormat._createFallbackFormat(aFallbackFormatOptions, oFormat.oFormatOptions.calendarType, oLocale, oInfo, oFormat.oFormatOptions);
|
339
350
|
}
|
340
351
|
oFormat.oRequiredParts = oInfo.oRequiredParts;
|
341
352
|
oFormat.aRelativeScales = oInfo.aRelativeScales;
|
@@ -394,10 +405,7 @@ DateFormat._createFallbackFormat = function (aFallbackFormatOptions, sCalendarTy
|
|
394
405
|
oFormatOptions.interval = true;
|
395
406
|
}
|
396
407
|
oFormatOptions.calendarType = sCalendarType;
|
397
|
-
oFormatOptions
|
398
|
-
var oFallbackFormat = DateFormat.createInstance(oFormatOptions, oLocale, oInfo);
|
399
|
-
oFallbackFormat.bIsFallback = true;
|
400
|
-
return oFallbackFormat;
|
408
|
+
return DateFormat.createInstance(oFormatOptions, oLocale, oInfo, true);
|
401
409
|
});
|
402
410
|
};
|
403
411
|
DateFormat._createFallbackOptionsWithoutDelimiter = function (sBasePattern) {
|
@@ -433,9 +441,6 @@ var oParseHelper = {
|
|
433
441
|
while (iLength < iMaxLength && this.isNumber(sValue.charCodeAt(iLength))) {
|
434
442
|
iLength++;
|
435
443
|
}
|
436
|
-
if (typeof sValue !== 'string') {
|
437
|
-
sValue = sValue.toString();
|
438
|
-
}
|
439
444
|
return sValue.substr(0, iLength);
|
440
445
|
},
|
441
446
|
startsWithIgnoreCase: function (sValue, sSubstring, sLocale) {
|
@@ -468,7 +473,7 @@ var oParseHelper = {
|
|
468
473
|
},
|
469
474
|
parseTZ: function (sValue, bColonSeparated) {
|
470
475
|
var iLength = 0;
|
471
|
-
var iTZFactor = sValue.charAt(0)
|
476
|
+
var iTZFactor = sValue.charAt(0) === '+' ? -1 : 1;
|
472
477
|
var sPart;
|
473
478
|
iLength++;
|
474
479
|
sPart = this.findNumbers(sValue.substr(iLength), 2);
|
@@ -488,14 +493,30 @@ var oParseHelper = {
|
|
488
493
|
tzDiff: (iTZDiff + 60 * iTZDiffHour) * 60 * iTZFactor
|
489
494
|
};
|
490
495
|
},
|
491
|
-
checkValid: function (
|
492
|
-
if (
|
496
|
+
checkValid: function (sSymbolName, bPartInvalid, oFormat) {
|
497
|
+
if (sSymbolName in oFormat.oRequiredParts && bPartInvalid) {
|
493
498
|
return false;
|
494
499
|
}
|
500
|
+
return true;
|
495
501
|
}
|
496
502
|
};
|
503
|
+
DateFormat._createPatternSymbol = function (mParameters) {
|
504
|
+
var fnIsNumeric = typeof mParameters.isNumeric === 'function' && mParameters.isNumeric || function () {
|
505
|
+
return mParameters.isNumeric || false;
|
506
|
+
};
|
507
|
+
return {
|
508
|
+
name: mParameters.name,
|
509
|
+
format: mParameters.format || function () {
|
510
|
+
return '';
|
511
|
+
},
|
512
|
+
parse: mParameters.parse || function () {
|
513
|
+
return {};
|
514
|
+
},
|
515
|
+
isNumeric: fnIsNumeric
|
516
|
+
};
|
517
|
+
};
|
497
518
|
DateFormat.prototype.oSymbols = {
|
498
|
-
'': {
|
519
|
+
'': DateFormat._createPatternSymbol({
|
499
520
|
name: 'text',
|
500
521
|
format: function (oField, oDate) {
|
501
522
|
return oField.value;
|
@@ -537,8 +558,8 @@ DateFormat.prototype.oSymbols = {
|
|
537
558
|
return { valid: oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat) };
|
538
559
|
}
|
539
560
|
}
|
540
|
-
},
|
541
|
-
'G': {
|
561
|
+
}),
|
562
|
+
'G': DateFormat._createPatternSymbol({
|
542
563
|
name: 'era',
|
543
564
|
format: function (oField, oDate, bUTC, oFormat) {
|
544
565
|
var iEra = oDate.getUTCEra();
|
@@ -571,34 +592,35 @@ DateFormat.prototype.oSymbols = {
|
|
571
592
|
valid: oParseHelper.checkValid(oPart.type, true, oFormat)
|
572
593
|
};
|
573
594
|
}
|
574
|
-
},
|
575
|
-
'y': {
|
595
|
+
}),
|
596
|
+
'y': DateFormat._createPatternSymbol({
|
576
597
|
name: 'year',
|
577
598
|
format: function (oField, oDate, bUTC, oFormat) {
|
578
599
|
var iYear = oDate.getUTCFullYear();
|
579
600
|
var sYear = String(iYear);
|
580
601
|
var sCalendarType = oFormat.oFormatOptions.calendarType;
|
581
|
-
if (oField.digits
|
602
|
+
if (oField.digits === 2 && sYear.length > 2) {
|
582
603
|
sYear = sYear.substr(sYear.length - 2);
|
583
604
|
}
|
584
|
-
if (sCalendarType
|
605
|
+
if (sCalendarType !== CalendarType.Japanese && oField.digits === 1 && iYear < 100) {
|
585
606
|
sYear = sYear.padStart(4, '0');
|
586
607
|
}
|
587
608
|
return sYear.padStart(oField.digits, '0');
|
588
609
|
},
|
589
610
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
590
|
-
var sCalendarType = oFormat.oFormatOptions.calendarType;
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
sPart = oParseHelper.findNumbers(sValue, 2);
|
611
|
+
var iExpectedDigits, sPart, bPartInvalid, sCalendarType = oFormat.oFormatOptions.calendarType;
|
612
|
+
if (oPart.digits === 1) {
|
613
|
+
iExpectedDigits = 4;
|
614
|
+
} else if (oPart.digits === 2) {
|
615
|
+
iExpectedDigits = 2;
|
596
616
|
} else {
|
597
|
-
|
617
|
+
iExpectedDigits = oPart.digits;
|
598
618
|
}
|
619
|
+
sPart = oParseHelper.findNumbers(sValue, iExpectedDigits);
|
620
|
+
bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length !== iExpectedDigits;
|
599
621
|
var iYear = parseInt(sPart);
|
600
|
-
if (sCalendarType
|
601
|
-
var oCurrentDate = UniversalDate.getInstance(
|
622
|
+
if (sCalendarType !== CalendarType.Japanese && sPart.length <= 2) {
|
623
|
+
var oCurrentDate = UniversalDate.getInstance(UI5Date.getInstance(), sCalendarType), iCurrentYear = oCurrentDate.getUTCFullYear(), iCurrentCentury = Math.floor(iCurrentYear / 100), iYearDiff = iCurrentCentury * 100 + iYear - iCurrentYear;
|
602
624
|
if (iYearDiff < -70) {
|
603
625
|
iYear += (iCurrentCentury + 1) * 100;
|
604
626
|
} else if (iYearDiff < 30) {
|
@@ -609,40 +631,42 @@ DateFormat.prototype.oSymbols = {
|
|
609
631
|
}
|
610
632
|
return {
|
611
633
|
length: sPart.length,
|
612
|
-
valid: oParseHelper.checkValid(oPart.type,
|
634
|
+
valid: oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat),
|
613
635
|
year: iYear
|
614
636
|
};
|
615
|
-
}
|
616
|
-
|
617
|
-
|
637
|
+
},
|
638
|
+
isNumeric: true
|
639
|
+
}),
|
640
|
+
'Y': DateFormat._createPatternSymbol({
|
618
641
|
name: 'weekYear',
|
619
642
|
format: function (oField, oDate, bUTC, oFormat) {
|
620
643
|
var oWeek = oDate.getUTCWeek(oFormat.oLocale, getCalendarWeekParameter(oFormat.oFormatOptions));
|
621
644
|
var iWeekYear = oWeek.year;
|
622
645
|
var sWeekYear = String(iWeekYear);
|
623
646
|
var sCalendarType = oFormat.oFormatOptions.calendarType;
|
624
|
-
if (oField.digits
|
647
|
+
if (oField.digits === 2 && sWeekYear.length > 2) {
|
625
648
|
sWeekYear = sWeekYear.substr(sWeekYear.length - 2);
|
626
649
|
}
|
627
|
-
if (sCalendarType
|
650
|
+
if (sCalendarType !== CalendarType.Japanese && oField.digits === 1 && iWeekYear < 100) {
|
628
651
|
sWeekYear = sWeekYear.padStart(4, '0');
|
629
652
|
}
|
630
653
|
return sWeekYear.padStart(oField.digits, '0');
|
631
654
|
},
|
632
655
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
633
|
-
var sCalendarType = oFormat.oFormatOptions.calendarType;
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
sPart = oParseHelper.findNumbers(sValue, 2);
|
656
|
+
var iExpectedDigits, sPart, bPartInvalid, sCalendarType = oFormat.oFormatOptions.calendarType;
|
657
|
+
if (oPart.digits === 1) {
|
658
|
+
iExpectedDigits = 4;
|
659
|
+
} else if (oPart.digits === 2) {
|
660
|
+
iExpectedDigits = 2;
|
639
661
|
} else {
|
640
|
-
|
662
|
+
iExpectedDigits = oPart.digits;
|
641
663
|
}
|
664
|
+
sPart = oParseHelper.findNumbers(sValue, iExpectedDigits);
|
665
|
+
bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length !== iExpectedDigits;
|
642
666
|
var iYear = parseInt(sPart);
|
643
667
|
var iWeekYear = iYear;
|
644
|
-
if (sCalendarType
|
645
|
-
var oCurrentDate = UniversalDate.getInstance(
|
668
|
+
if (sCalendarType !== CalendarType.Japanese && sPart.length <= 2) {
|
669
|
+
var oCurrentDate = UniversalDate.getInstance(UI5Date.getInstance(), sCalendarType), iCurrentYear = oCurrentDate.getUTCFullYear(), iCurrentCentury = Math.floor(iCurrentYear / 100), iYearDiff = iCurrentCentury * 100 + iWeekYear - iCurrentYear;
|
646
670
|
if (iYearDiff < -70) {
|
647
671
|
iWeekYear += (iCurrentCentury + 1) * 100;
|
648
672
|
} else if (iYearDiff < 30) {
|
@@ -653,19 +677,20 @@ DateFormat.prototype.oSymbols = {
|
|
653
677
|
}
|
654
678
|
return {
|
655
679
|
length: sPart.length,
|
656
|
-
valid: oParseHelper.checkValid(oPart.type,
|
680
|
+
valid: oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat),
|
657
681
|
year: iYear,
|
658
682
|
weekYear: iWeekYear
|
659
683
|
};
|
660
|
-
}
|
661
|
-
|
662
|
-
|
684
|
+
},
|
685
|
+
isNumeric: true
|
686
|
+
}),
|
687
|
+
'M': DateFormat._createPatternSymbol({
|
663
688
|
name: 'month',
|
664
689
|
format: function (oField, oDate, bUTC, oFormat) {
|
665
690
|
var iMonth = oDate.getUTCMonth();
|
666
|
-
if (oField.digits
|
691
|
+
if (oField.digits === 3) {
|
667
692
|
return oFormat.aMonthsAbbrev[iMonth];
|
668
|
-
} else if (oField.digits
|
693
|
+
} else if (oField.digits === 4) {
|
669
694
|
return oFormat.aMonthsWide[iMonth];
|
670
695
|
} else if (oField.digits > 4) {
|
671
696
|
return oFormat.aMonthsNarrow[iMonth];
|
@@ -674,20 +699,18 @@ DateFormat.prototype.oSymbols = {
|
|
674
699
|
}
|
675
700
|
},
|
676
701
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
677
|
-
var aMonthsVariants = [
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
var bValid;
|
686
|
-
var iMonth;
|
687
|
-
var sPart;
|
702
|
+
var iMonth, sPart, bPartInvalid, bValid, aMonthsVariants = [
|
703
|
+
oFormat.aMonthsWide,
|
704
|
+
oFormat.aMonthsWideSt,
|
705
|
+
oFormat.aMonthsAbbrev,
|
706
|
+
oFormat.aMonthsAbbrevSt,
|
707
|
+
oFormat.aMonthsNarrow,
|
708
|
+
oFormat.aMonthsNarrowSt
|
709
|
+
];
|
688
710
|
if (oPart.digits < 3) {
|
689
711
|
sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
690
|
-
|
712
|
+
bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2;
|
713
|
+
bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
691
714
|
iMonth = parseInt(sPart) - 1;
|
692
715
|
if (oConfig.strict && (iMonth > 11 || iMonth < 0)) {
|
693
716
|
bValid = false;
|
@@ -710,15 +733,18 @@ DateFormat.prototype.oSymbols = {
|
|
710
733
|
length: sPart ? sPart.length : 0,
|
711
734
|
valid: bValid
|
712
735
|
};
|
736
|
+
},
|
737
|
+
isNumeric: function (iDigits) {
|
738
|
+
return iDigits < 3;
|
713
739
|
}
|
714
|
-
},
|
715
|
-
'L': {
|
740
|
+
}),
|
741
|
+
'L': DateFormat._createPatternSymbol({
|
716
742
|
name: 'monthStandalone',
|
717
743
|
format: function (oField, oDate, bUTC, oFormat) {
|
718
744
|
var iMonth = oDate.getUTCMonth();
|
719
|
-
if (oField.digits
|
745
|
+
if (oField.digits === 3) {
|
720
746
|
return oFormat.aMonthsAbbrevSt[iMonth];
|
721
|
-
} else if (oField.digits
|
747
|
+
} else if (oField.digits === 4) {
|
722
748
|
return oFormat.aMonthsWideSt[iMonth];
|
723
749
|
} else if (oField.digits > 4) {
|
724
750
|
return oFormat.aMonthsNarrowSt[iMonth];
|
@@ -727,20 +753,18 @@ DateFormat.prototype.oSymbols = {
|
|
727
753
|
}
|
728
754
|
},
|
729
755
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
730
|
-
var aMonthsVariants = [
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
var bValid;
|
739
|
-
var iMonth;
|
740
|
-
var sPart;
|
756
|
+
var iMonth, sPart, bPartInvalid, bValid, aMonthsVariants = [
|
757
|
+
oFormat.aMonthsWide,
|
758
|
+
oFormat.aMonthsWideSt,
|
759
|
+
oFormat.aMonthsAbbrev,
|
760
|
+
oFormat.aMonthsAbbrevSt,
|
761
|
+
oFormat.aMonthsNarrow,
|
762
|
+
oFormat.aMonthsNarrowSt
|
763
|
+
];
|
741
764
|
if (oPart.digits < 3) {
|
742
765
|
sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
743
|
-
|
766
|
+
bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2;
|
767
|
+
bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
744
768
|
iMonth = parseInt(sPart) - 1;
|
745
769
|
if (oConfig.strict && (iMonth > 11 || iMonth < 0)) {
|
746
770
|
bValid = false;
|
@@ -763,9 +787,12 @@ DateFormat.prototype.oSymbols = {
|
|
763
787
|
length: sPart ? sPart.length : 0,
|
764
788
|
valid: bValid
|
765
789
|
};
|
790
|
+
},
|
791
|
+
isNumeric: function (iDigits) {
|
792
|
+
return iDigits < 3;
|
766
793
|
}
|
767
|
-
},
|
768
|
-
'w': {
|
794
|
+
}),
|
795
|
+
'w': DateFormat._createPatternSymbol({
|
769
796
|
name: 'weekInYear',
|
770
797
|
format: function (oField, oDate, bUTC, oFormat) {
|
771
798
|
var oWeek = oDate.getUTCWeek(oFormat.oLocale, getCalendarWeekParameter(oFormat.oFormatOptions));
|
@@ -779,15 +806,13 @@ DateFormat.prototype.oSymbols = {
|
|
779
806
|
return sWeek;
|
780
807
|
},
|
781
808
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
782
|
-
var bValid;
|
783
|
-
var sPart;
|
784
|
-
var iWeek;
|
785
|
-
var iLength = 0;
|
809
|
+
var sPart, bPartInvalid, bValid, iWeek, iLength = 0;
|
786
810
|
if (oPart.digits < 3) {
|
787
811
|
sPart = oParseHelper.findNumbers(sValue, 2);
|
788
812
|
iLength = sPart.length;
|
789
813
|
iWeek = parseInt(sPart) - 1;
|
790
|
-
|
814
|
+
bPartInvalid = !sPart || oConfig.exactLength && iLength < 2;
|
815
|
+
bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
791
816
|
} else {
|
792
817
|
sPart = oFormat.oLocaleData.getCalendarWeek(oPart.digits === 3 ? 'narrow' : 'wide');
|
793
818
|
sPart = sPart.replace('{0}', '([0-9]+)');
|
@@ -804,35 +829,21 @@ DateFormat.prototype.oSymbols = {
|
|
804
829
|
valid: bValid,
|
805
830
|
week: iWeek
|
806
831
|
};
|
807
|
-
}
|
808
|
-
},
|
809
|
-
'W': {
|
810
|
-
name: 'weekInMonth',
|
811
|
-
format: function (oField, oDate) {
|
812
|
-
return '';
|
813
832
|
},
|
814
|
-
|
815
|
-
return
|
816
|
-
}
|
817
|
-
},
|
818
|
-
'D': {
|
819
|
-
name: 'dayInYear',
|
820
|
-
format: function (oField, oDate) {
|
821
|
-
},
|
822
|
-
parse: function () {
|
823
|
-
return {};
|
833
|
+
isNumeric: function (iDigits) {
|
834
|
+
return iDigits < 3;
|
824
835
|
}
|
825
|
-
},
|
826
|
-
'
|
836
|
+
}),
|
837
|
+
'W': DateFormat._createPatternSymbol({ name: 'weekInMonth' }),
|
838
|
+
'D': DateFormat._createPatternSymbol({ name: 'dayInYear' }),
|
839
|
+
'd': DateFormat._createPatternSymbol({
|
827
840
|
name: 'day',
|
828
841
|
format: function (oField, oDate) {
|
829
842
|
var iDate = oDate.getUTCDate();
|
830
843
|
return String(iDate).padStart(oField.digits, '0');
|
831
844
|
},
|
832
845
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
833
|
-
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
834
|
-
var bValid = oParseHelper.checkValid(oPart.type, sPart === '', oFormat);
|
835
|
-
var iDay = parseInt(sPart);
|
846
|
+
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2)), bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2, bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat), iDay = parseInt(sPart);
|
836
847
|
if (oConfig.strict && (iDay > 31 || iDay < 1)) {
|
837
848
|
bValid = false;
|
838
849
|
}
|
@@ -841,15 +852,16 @@ DateFormat.prototype.oSymbols = {
|
|
841
852
|
length: sPart.length,
|
842
853
|
valid: bValid
|
843
854
|
};
|
844
|
-
}
|
845
|
-
|
846
|
-
|
855
|
+
},
|
856
|
+
isNumeric: true
|
857
|
+
}),
|
858
|
+
'Q': DateFormat._createPatternSymbol({
|
847
859
|
name: 'quarter',
|
848
860
|
format: function (oField, oDate, bUTC, oFormat) {
|
849
861
|
var iQuarter = oDate.getUTCQuarter();
|
850
|
-
if (oField.digits
|
862
|
+
if (oField.digits === 3) {
|
851
863
|
return oFormat.aQuartersAbbrev[iQuarter];
|
852
|
-
} else if (oField.digits
|
864
|
+
} else if (oField.digits === 4) {
|
853
865
|
return oFormat.aQuartersWide[iQuarter];
|
854
866
|
} else if (oField.digits > 4) {
|
855
867
|
return oFormat.aQuartersNarrow[iQuarter];
|
@@ -858,9 +870,7 @@ DateFormat.prototype.oSymbols = {
|
|
858
870
|
}
|
859
871
|
},
|
860
872
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
861
|
-
var bValid;
|
862
|
-
var iQuarter;
|
863
|
-
var sPart;
|
873
|
+
var sPart, bPartInvalid, iQuarter, bValid;
|
864
874
|
var aQuartersVariants = [
|
865
875
|
oFormat.aQuartersWide,
|
866
876
|
oFormat.aQuartersWideSt,
|
@@ -871,7 +881,8 @@ DateFormat.prototype.oSymbols = {
|
|
871
881
|
];
|
872
882
|
if (oPart.digits < 3) {
|
873
883
|
sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
874
|
-
|
884
|
+
bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2;
|
885
|
+
bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
875
886
|
iQuarter = parseInt(sPart) - 1;
|
876
887
|
if (oConfig.strict && iQuarter > 3) {
|
877
888
|
bValid = false;
|
@@ -894,15 +905,18 @@ DateFormat.prototype.oSymbols = {
|
|
894
905
|
quarter: iQuarter,
|
895
906
|
valid: bValid
|
896
907
|
};
|
908
|
+
},
|
909
|
+
isNumeric: function (iDigits) {
|
910
|
+
return iDigits < 3;
|
897
911
|
}
|
898
|
-
},
|
899
|
-
'q': {
|
912
|
+
}),
|
913
|
+
'q': DateFormat._createPatternSymbol({
|
900
914
|
name: 'quarterStandalone',
|
901
915
|
format: function (oField, oDate, bUTC, oFormat) {
|
902
916
|
var iQuarter = oDate.getUTCQuarter();
|
903
|
-
if (oField.digits
|
917
|
+
if (oField.digits === 3) {
|
904
918
|
return oFormat.aQuartersAbbrevSt[iQuarter];
|
905
|
-
} else if (oField.digits
|
919
|
+
} else if (oField.digits === 4) {
|
906
920
|
return oFormat.aQuartersWideSt[iQuarter];
|
907
921
|
} else if (oField.digits > 4) {
|
908
922
|
return oFormat.aQuartersNarrowSt[iQuarter];
|
@@ -911,9 +925,7 @@ DateFormat.prototype.oSymbols = {
|
|
911
925
|
}
|
912
926
|
},
|
913
927
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
914
|
-
var bValid;
|
915
|
-
var iQuarter;
|
916
|
-
var sPart;
|
928
|
+
var sPart, bPartInvalid, iQuarter, bValid;
|
917
929
|
var aQuartersVariants = [
|
918
930
|
oFormat.aQuartersWide,
|
919
931
|
oFormat.aQuartersWideSt,
|
@@ -924,7 +936,8 @@ DateFormat.prototype.oSymbols = {
|
|
924
936
|
];
|
925
937
|
if (oPart.digits < 3) {
|
926
938
|
sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
927
|
-
|
939
|
+
bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2;
|
940
|
+
bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
928
941
|
iQuarter = parseInt(sPart) - 1;
|
929
942
|
if (oConfig.strict && iQuarter > 3) {
|
930
943
|
bValid = false;
|
@@ -947,26 +960,21 @@ DateFormat.prototype.oSymbols = {
|
|
947
960
|
quarter: iQuarter,
|
948
961
|
valid: bValid
|
949
962
|
};
|
950
|
-
}
|
951
|
-
},
|
952
|
-
'F': {
|
953
|
-
name: 'dayOfWeekInMonth',
|
954
|
-
format: function (oField, oDate, oFormat) {
|
955
|
-
return '';
|
956
963
|
},
|
957
|
-
|
958
|
-
return
|
964
|
+
isNumeric: function (iDigits) {
|
965
|
+
return iDigits < 3;
|
959
966
|
}
|
960
|
-
},
|
961
|
-
'
|
967
|
+
}),
|
968
|
+
'F': DateFormat._createPatternSymbol({ name: 'dayOfWeekInMonth' }),
|
969
|
+
'E': DateFormat._createPatternSymbol({
|
962
970
|
name: 'dayNameInWeek',
|
963
971
|
format: function (oField, oDate, bUTC, oFormat) {
|
964
972
|
var iDay = oDate.getUTCDay();
|
965
973
|
if (oField.digits < 4) {
|
966
974
|
return oFormat.aDaysAbbrev[iDay];
|
967
|
-
} else if (oField.digits
|
975
|
+
} else if (oField.digits === 4) {
|
968
976
|
return oFormat.aDaysWide[iDay];
|
969
|
-
} else if (oField.digits
|
977
|
+
} else if (oField.digits === 5) {
|
970
978
|
return oFormat.aDaysNarrow[iDay];
|
971
979
|
} else {
|
972
980
|
return oFormat.aDaysShort[iDay];
|
@@ -994,16 +1002,16 @@ DateFormat.prototype.oSymbols = {
|
|
994
1002
|
}
|
995
1003
|
}
|
996
1004
|
}
|
997
|
-
},
|
998
|
-
'c': {
|
1005
|
+
}),
|
1006
|
+
'c': DateFormat._createPatternSymbol({
|
999
1007
|
name: 'dayNameInWeekStandalone',
|
1000
1008
|
format: function (oField, oDate, bUTC, oFormat) {
|
1001
1009
|
var iDay = oDate.getUTCDay();
|
1002
1010
|
if (oField.digits < 4) {
|
1003
1011
|
return oFormat.aDaysAbbrevSt[iDay];
|
1004
|
-
} else if (oField.digits
|
1012
|
+
} else if (oField.digits === 4) {
|
1005
1013
|
return oFormat.aDaysWideSt[iDay];
|
1006
|
-
} else if (oField.digits
|
1014
|
+
} else if (oField.digits === 5) {
|
1007
1015
|
return oFormat.aDaysNarrowSt[iDay];
|
1008
1016
|
} else {
|
1009
1017
|
return oFormat.aDaysShortSt[iDay];
|
@@ -1031,22 +1039,24 @@ DateFormat.prototype.oSymbols = {
|
|
1031
1039
|
}
|
1032
1040
|
}
|
1033
1041
|
}
|
1034
|
-
},
|
1035
|
-
'u': {
|
1042
|
+
}),
|
1043
|
+
'u': DateFormat._createPatternSymbol({
|
1036
1044
|
name: 'dayNumberOfWeek',
|
1037
1045
|
format: function (oField, oDate, bUTC, oFormat) {
|
1038
1046
|
var iDay = oDate.getUTCDay();
|
1039
1047
|
return oFormat._adaptDayOfWeek(iDay);
|
1040
1048
|
},
|
1041
1049
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1042
|
-
var sPart = oParseHelper.findNumbers(sValue, oPart.digits);
|
1050
|
+
var sPart = oParseHelper.findNumbers(sValue, oPart.digits), bPartInvalid = oConfig.exactLength && sPart.length !== oPart.digits;
|
1043
1051
|
return {
|
1044
1052
|
dayNumberOfWeek: parseInt(sPart),
|
1045
|
-
length: sPart.length
|
1053
|
+
length: sPart.length,
|
1054
|
+
valid: oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat)
|
1046
1055
|
};
|
1047
|
-
}
|
1048
|
-
|
1049
|
-
|
1056
|
+
},
|
1057
|
+
isNumeric: true
|
1058
|
+
}),
|
1059
|
+
'a': DateFormat._createPatternSymbol({
|
1050
1060
|
name: 'amPmMarker',
|
1051
1061
|
format: function (oField, oDate, bUTC, oFormat) {
|
1052
1062
|
var iDayPeriod = oDate.getUTCDayPeriod();
|
@@ -1088,8 +1098,8 @@ DateFormat.prototype.oSymbols = {
|
|
1088
1098
|
}
|
1089
1099
|
return { valid: false };
|
1090
1100
|
}
|
1091
|
-
},
|
1092
|
-
'B': {
|
1101
|
+
}),
|
1102
|
+
'B': DateFormat._createPatternSymbol({
|
1093
1103
|
name: 'flexibleDayPeriod',
|
1094
1104
|
format: function (oField, oDate, bUTC, oFormat) {
|
1095
1105
|
var bContainsHour = oFormat.aFormatArray.some(function (oFormatElement) {
|
@@ -1134,18 +1144,15 @@ DateFormat.prototype.oSymbols = {
|
|
1134
1144
|
}
|
1135
1145
|
return { valid: false };
|
1136
1146
|
}
|
1137
|
-
},
|
1138
|
-
'H': {
|
1147
|
+
}),
|
1148
|
+
'H': DateFormat._createPatternSymbol({
|
1139
1149
|
name: 'hour0_23',
|
1140
1150
|
format: function (oField, oDate) {
|
1141
1151
|
var iHours = oDate.getUTCHours();
|
1142
1152
|
return String(iHours).padStart(oField.digits, '0');
|
1143
1153
|
},
|
1144
1154
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1145
|
-
var bValid;
|
1146
|
-
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
1147
|
-
var iHours = parseInt(sPart);
|
1148
|
-
bValid = oParseHelper.checkValid(oPart.type, sPart === '', oFormat);
|
1155
|
+
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2)), iHours = parseInt(sPart), bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2, bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
1149
1156
|
if (oConfig.strict && iHours > 23) {
|
1150
1157
|
bValid = false;
|
1151
1158
|
}
|
@@ -1154,9 +1161,10 @@ DateFormat.prototype.oSymbols = {
|
|
1154
1161
|
length: sPart.length,
|
1155
1162
|
valid: bValid
|
1156
1163
|
};
|
1157
|
-
}
|
1158
|
-
|
1159
|
-
|
1164
|
+
},
|
1165
|
+
isNumeric: true
|
1166
|
+
}),
|
1167
|
+
'k': DateFormat._createPatternSymbol({
|
1160
1168
|
name: 'hour1_24',
|
1161
1169
|
format: function (oField, oDate) {
|
1162
1170
|
var iHours = oDate.getUTCHours();
|
@@ -1164,11 +1172,8 @@ DateFormat.prototype.oSymbols = {
|
|
1164
1172
|
return sHours.padStart(oField.digits, '0');
|
1165
1173
|
},
|
1166
1174
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1167
|
-
var bValid;
|
1168
|
-
|
1169
|
-
var iHours = parseInt(sPart);
|
1170
|
-
bValid = oParseHelper.checkValid(oPart.type, sPart === '', oFormat);
|
1171
|
-
if (iHours == 24) {
|
1175
|
+
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2)), iHours = parseInt(sPart), bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2, bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
1176
|
+
if (iHours === 24) {
|
1172
1177
|
iHours = 0;
|
1173
1178
|
}
|
1174
1179
|
if (oConfig.strict && iHours > 23) {
|
@@ -1179,9 +1184,10 @@ DateFormat.prototype.oSymbols = {
|
|
1179
1184
|
length: sPart.length,
|
1180
1185
|
valid: bValid
|
1181
1186
|
};
|
1182
|
-
}
|
1183
|
-
|
1184
|
-
|
1187
|
+
},
|
1188
|
+
isNumeric: true
|
1189
|
+
}),
|
1190
|
+
'K': DateFormat._createPatternSymbol({
|
1185
1191
|
name: 'hour0_11',
|
1186
1192
|
format: function (oField, oDate) {
|
1187
1193
|
var iHours = oDate.getUTCHours();
|
@@ -1189,10 +1195,7 @@ DateFormat.prototype.oSymbols = {
|
|
1189
1195
|
return sHours.padStart(oField.digits, '0');
|
1190
1196
|
},
|
1191
1197
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1192
|
-
var bValid;
|
1193
|
-
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
1194
|
-
var iHours = parseInt(sPart);
|
1195
|
-
bValid = oParseHelper.checkValid(oPart.type, sPart === '', oFormat);
|
1198
|
+
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2)), iHours = parseInt(sPart), bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2, bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
1196
1199
|
if (oConfig.strict && iHours > 11) {
|
1197
1200
|
bValid = false;
|
1198
1201
|
}
|
@@ -1201,16 +1204,17 @@ DateFormat.prototype.oSymbols = {
|
|
1201
1204
|
length: sPart.length,
|
1202
1205
|
valid: bValid
|
1203
1206
|
};
|
1204
|
-
}
|
1205
|
-
|
1206
|
-
|
1207
|
+
},
|
1208
|
+
isNumeric: true
|
1209
|
+
}),
|
1210
|
+
'h': DateFormat._createPatternSymbol({
|
1207
1211
|
name: 'hour1_12',
|
1208
1212
|
format: function (oField, oDate) {
|
1209
1213
|
var iHours = oDate.getUTCHours();
|
1210
1214
|
var sHours;
|
1211
1215
|
if (iHours > 12) {
|
1212
1216
|
sHours = String(iHours - 12);
|
1213
|
-
} else if (iHours
|
1217
|
+
} else if (iHours === 0) {
|
1214
1218
|
sHours = '12';
|
1215
1219
|
} else {
|
1216
1220
|
sHours = String(iHours);
|
@@ -1218,11 +1222,8 @@ DateFormat.prototype.oSymbols = {
|
|
1218
1222
|
return sHours.padStart(oField.digits, '0');
|
1219
1223
|
},
|
1220
1224
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1221
|
-
var bPM = oConfig.dateValue.pm;
|
1222
|
-
|
1223
|
-
var iHours = parseInt(sPart);
|
1224
|
-
var bValid = oParseHelper.checkValid(oPart.type, sPart === '', oFormat);
|
1225
|
-
if (iHours == 12) {
|
1225
|
+
var bPM = oConfig.dateValue.pm, sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2)), iHours = parseInt(sPart), bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2, bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
1226
|
+
if (iHours === 12) {
|
1226
1227
|
iHours = 0;
|
1227
1228
|
bPM = bPM === undefined ? true : bPM;
|
1228
1229
|
}
|
@@ -1235,19 +1236,17 @@ DateFormat.prototype.oSymbols = {
|
|
1235
1236
|
pm: bPM,
|
1236
1237
|
valid: bValid
|
1237
1238
|
};
|
1238
|
-
}
|
1239
|
-
|
1240
|
-
|
1239
|
+
},
|
1240
|
+
isNumeric: true
|
1241
|
+
}),
|
1242
|
+
'm': DateFormat._createPatternSymbol({
|
1241
1243
|
name: 'minute',
|
1242
1244
|
format: function (oField, oDate) {
|
1243
1245
|
var iMinutes = oDate.getUTCMinutes();
|
1244
1246
|
return String(iMinutes).padStart(oField.digits, '0');
|
1245
1247
|
},
|
1246
1248
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1247
|
-
var bValid;
|
1248
|
-
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
1249
|
-
var iMinutes = parseInt(sPart);
|
1250
|
-
bValid = oParseHelper.checkValid(oPart.type, sPart === '', oFormat);
|
1249
|
+
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2)), iMinutes = parseInt(sPart), bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < 2, bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
1251
1250
|
if (oConfig.strict && iMinutes > 59) {
|
1252
1251
|
bValid = false;
|
1253
1252
|
}
|
@@ -1256,19 +1255,17 @@ DateFormat.prototype.oSymbols = {
|
|
1256
1255
|
minute: iMinutes,
|
1257
1256
|
valid: bValid
|
1258
1257
|
};
|
1259
|
-
}
|
1260
|
-
|
1261
|
-
|
1258
|
+
},
|
1259
|
+
isNumeric: true
|
1260
|
+
}),
|
1261
|
+
's': DateFormat._createPatternSymbol({
|
1262
1262
|
name: 'second',
|
1263
1263
|
format: function (oField, oDate) {
|
1264
1264
|
var iSeconds = oDate.getUTCSeconds();
|
1265
1265
|
return String(iSeconds).padStart(oField.digits, '0');
|
1266
1266
|
},
|
1267
1267
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1268
|
-
var bValid;
|
1269
|
-
var sPart = oParseHelper.findNumbers(sValue, Math.max(oPart.digits, 2));
|
1270
|
-
var iSeconds = parseInt(sPart);
|
1271
|
-
bValid = oParseHelper.checkValid(oPart.type, sPart === '', oFormat);
|
1268
|
+
var iExpectedDigits = Math.max(oPart.digits, 2), sPart = oParseHelper.findNumbers(sValue, iExpectedDigits), bPartInvalid = sPart === '' || oConfig.exactLength && sPart.length < iExpectedDigits, iSeconds = parseInt(sPart), bValid = oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat);
|
1272
1269
|
if (oConfig.strict && iSeconds > 59) {
|
1273
1270
|
bValid = false;
|
1274
1271
|
}
|
@@ -1277,9 +1274,10 @@ DateFormat.prototype.oSymbols = {
|
|
1277
1274
|
second: iSeconds,
|
1278
1275
|
valid: bValid
|
1279
1276
|
};
|
1280
|
-
}
|
1281
|
-
|
1282
|
-
|
1277
|
+
},
|
1278
|
+
isNumeric: true
|
1279
|
+
}),
|
1280
|
+
'S': DateFormat._createPatternSymbol({
|
1283
1281
|
name: 'fractionalsecond',
|
1284
1282
|
format: function (oField, oDate) {
|
1285
1283
|
var iMilliseconds = oDate.getUTCMilliseconds();
|
@@ -1290,18 +1288,19 @@ DateFormat.prototype.oSymbols = {
|
|
1290
1288
|
return sFractionalseconds;
|
1291
1289
|
},
|
1292
1290
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1293
|
-
var sPart = oParseHelper.findNumbers(sValue, oPart.digits);
|
1294
|
-
var iLength = sPart.length;
|
1291
|
+
var sPart = oParseHelper.findNumbers(sValue, oPart.digits), iLength = sPart.length, bPartInvalid = oConfig.exactLength && iLength < oPart.digits;
|
1295
1292
|
sPart = sPart.substr(0, 3);
|
1296
1293
|
sPart = sPart.padEnd(3, '0');
|
1297
1294
|
var iMilliseconds = parseInt(sPart);
|
1298
1295
|
return {
|
1299
1296
|
length: iLength,
|
1300
|
-
millisecond: iMilliseconds
|
1297
|
+
millisecond: iMilliseconds,
|
1298
|
+
valid: oParseHelper.checkValid(oPart.type, bPartInvalid, oFormat)
|
1301
1299
|
};
|
1302
|
-
}
|
1303
|
-
|
1304
|
-
|
1300
|
+
},
|
1301
|
+
isNumeric: true
|
1302
|
+
}),
|
1303
|
+
'z': DateFormat._createPatternSymbol({
|
1305
1304
|
name: 'timezoneGeneral',
|
1306
1305
|
format: function (oField, oDate, bUTC, oFormat, sTimezone) {
|
1307
1306
|
if (oField.digits > 3 && oDate.getTimezoneLong && oDate.getTimezoneLong()) {
|
@@ -1315,7 +1314,7 @@ DateFormat.prototype.oSymbols = {
|
|
1315
1314
|
var bPositiveOffset = iTimezoneOffset > 0;
|
1316
1315
|
var iHourOffset = Math.floor(iTZOffset / 60);
|
1317
1316
|
var iMinuteOffset = Math.floor(iTZOffset % 60);
|
1318
|
-
if (!bUTC && iTZOffset
|
1317
|
+
if (!bUTC && iTZOffset !== 0) {
|
1319
1318
|
sTimeZone += bPositiveOffset ? '-' : '+';
|
1320
1319
|
sTimeZone += String(iHourOffset).padStart(2, '0');
|
1321
1320
|
sTimeZone += ':';
|
@@ -1349,8 +1348,8 @@ DateFormat.prototype.oSymbols = {
|
|
1349
1348
|
tzDiff: iTZDiff
|
1350
1349
|
};
|
1351
1350
|
}
|
1352
|
-
},
|
1353
|
-
'Z': {
|
1351
|
+
}),
|
1352
|
+
'Z': DateFormat._createPatternSymbol({
|
1354
1353
|
name: 'timezoneRFC822',
|
1355
1354
|
format: function (oField, oDate, bUTC, oFormat, sTimezone) {
|
1356
1355
|
var iTimezoneOffset = TimezoneUtil.calculateOffset(oDate, sTimezone);
|
@@ -1369,8 +1368,8 @@ DateFormat.prototype.oSymbols = {
|
|
1369
1368
|
parse: function (sValue, oPart, oFormat, oConfig) {
|
1370
1369
|
return oParseHelper.parseTZ(sValue, false);
|
1371
1370
|
}
|
1372
|
-
},
|
1373
|
-
'X': {
|
1371
|
+
}),
|
1372
|
+
'X': DateFormat._createPatternSymbol({
|
1374
1373
|
name: 'timezoneISO8601',
|
1375
1374
|
format: function (oField, oDate, bUTC, oFormat, sTimezone) {
|
1376
1375
|
var iTimezoneOffset = TimezoneUtil.calculateOffset(oDate, sTimezone);
|
@@ -1379,7 +1378,7 @@ DateFormat.prototype.oSymbols = {
|
|
1379
1378
|
var iHourOffset = Math.floor(iTZOffset / 60);
|
1380
1379
|
var iMinuteOffset = Math.floor(iTZOffset % 60);
|
1381
1380
|
var sTimeZone = '';
|
1382
|
-
if (!bUTC && iTZOffset
|
1381
|
+
if (!bUTC && iTZOffset !== 0) {
|
1383
1382
|
sTimeZone += bPositiveOffset ? '-' : '+';
|
1384
1383
|
sTimeZone += String(iHourOffset).padStart(2, '0');
|
1385
1384
|
if (oField.digits > 1 || iMinuteOffset > 0) {
|
@@ -1403,8 +1402,8 @@ DateFormat.prototype.oSymbols = {
|
|
1403
1402
|
return oParseHelper.parseTZ(sValue, oPart.digits === 3 || oPart.digits === 5);
|
1404
1403
|
}
|
1405
1404
|
}
|
1406
|
-
},
|
1407
|
-
'V': {
|
1405
|
+
}),
|
1406
|
+
'V': DateFormat._createPatternSymbol({
|
1408
1407
|
name: 'timezoneID',
|
1409
1408
|
format: function (oField, oDate, bUTC, oFormat, sTimezone) {
|
1410
1409
|
if (!bUTC && oField.digits === 2) {
|
@@ -1444,7 +1443,7 @@ DateFormat.prototype.oSymbols = {
|
|
1444
1443
|
}
|
1445
1444
|
return oTimezoneParsed;
|
1446
1445
|
}
|
1447
|
-
}
|
1446
|
+
})
|
1448
1447
|
};
|
1449
1448
|
DateFormat.prototype._format = function (oJSDate, bUTC, sTimezone) {
|
1450
1449
|
if (this.oFormatOptions.relative) {
|
@@ -1532,30 +1531,36 @@ DateFormat.prototype.format = function (vJSDate, bUTC) {
|
|
1532
1531
|
vJSDate = convertToTimezone(vJSDate, sTimezone, bUTC);
|
1533
1532
|
sResult = this._format(vJSDate, bUTC, sTimezone);
|
1534
1533
|
}
|
1535
|
-
if (sCalendarType
|
1534
|
+
if (sCalendarType === CalendarType.Japanese && this.oLocale.getLanguage() === 'ja') {
|
1536
1535
|
sResult = sResult.replace(/(^|[^\d])1年/g, '$1元年');
|
1537
1536
|
}
|
1538
1537
|
return sResult;
|
1539
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
|
+
};
|
1540
1552
|
DateFormat.prototype._formatInterval = function (aJSDates, bUTC) {
|
1541
|
-
var sCalendarType = this.oFormatOptions.calendarType
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
var sSymbol;
|
1547
|
-
var aBuffer = [];
|
1548
|
-
var sPattern;
|
1549
|
-
var aFormatArray = [];
|
1550
|
-
var oDiffField = this._getGreatestDiffField([
|
1551
|
-
oFromDate,
|
1552
|
-
oToDate
|
1553
|
-
]);
|
1554
|
-
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) {
|
1555
1558
|
return this._format(aJSDates[0], bUTC);
|
1556
1559
|
}
|
1557
|
-
if (this.
|
1558
|
-
sPattern = this.
|
1560
|
+
if (this._useCustomIntervalDelimiter(oDiffFields)) {
|
1561
|
+
sPattern = this.intervalPatterns[0];
|
1562
|
+
} else if (this.oFormatOptions.format) {
|
1563
|
+
sPattern = this.oLocaleData.getCustomIntervalPattern(this.oFormatOptions.format, oDiffFields, sCalendarType);
|
1559
1564
|
} else {
|
1560
1565
|
sPattern = this.oLocaleData.getCombinedIntervalPattern(this.oFormatOptions.pattern, sCalendarType);
|
1561
1566
|
}
|
@@ -1583,7 +1588,7 @@ var mFieldToGroup = {
|
|
1583
1588
|
Minutes: 'Minute',
|
1584
1589
|
Seconds: 'Second'
|
1585
1590
|
};
|
1586
|
-
DateFormat.prototype.
|
1591
|
+
DateFormat.prototype._getDiffFields = function (aDates) {
|
1587
1592
|
var bDiffFound = false, mDiff = {};
|
1588
1593
|
this.aIntervalCompareFields.forEach(function (sField) {
|
1589
1594
|
var sGetterPrefix = 'getUTC', sMethodName = sGetterPrefix + sField, sFieldGroup = mFieldToGroup[sField], vFromValue = aDates[0][sMethodName].apply(aDates[0]), vToValue = aDates[1][sMethodName].apply(aDates[1]);
|
@@ -1598,21 +1603,28 @@ DateFormat.prototype._getGreatestDiffField = function (aDates) {
|
|
1598
1603
|
return null;
|
1599
1604
|
};
|
1600
1605
|
DateFormat.prototype._parse = function (sValue, aFormatArray, bUTC, bStrict, sTimezone) {
|
1601
|
-
var
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1606
|
+
var sFlexibleDayPeriod, oNextPart, oPart, bPM, oPrevPart, oResult, sSubValue, oDateValue = {
|
1607
|
+
valid: true,
|
1608
|
+
lastTimezonePatternSymbol: ''
|
1609
|
+
}, iIndex = 0, oParseConf = {
|
1610
|
+
formatArray: aFormatArray,
|
1611
|
+
dateValue: oDateValue,
|
1612
|
+
strict: bStrict
|
1613
|
+
}, that = this;
|
1614
|
+
function getSymbol(oPart0) {
|
1615
|
+
return that.oSymbols[oPart0.symbol || ''];
|
1616
|
+
}
|
1617
|
+
function isNumeric(oPart0) {
|
1618
|
+
return !!oPart0 && getSymbol(oPart0).isNumeric(oPart0.digits);
|
1619
|
+
}
|
1611
1620
|
for (var i = 0; i < aFormatArray.length; i++) {
|
1612
1621
|
sSubValue = sValue.substr(iIndex);
|
1613
1622
|
oPart = aFormatArray[i];
|
1623
|
+
oPrevPart = aFormatArray[i - 1];
|
1624
|
+
oNextPart = aFormatArray[i + 1];
|
1614
1625
|
oParseConf.index = i;
|
1615
|
-
|
1626
|
+
oParseConf.exactLength = isNumeric(oPart) && (isNumeric(oPrevPart) || isNumeric(oNextPart));
|
1627
|
+
oResult = getSymbol(oPart).parse(sSubValue, oPart, this, oParseConf, sTimezone) || {};
|
1616
1628
|
if (oResult.tzDiff !== undefined || oResult.timezone) {
|
1617
1629
|
oResult.lastTimezonePatternSymbol = oPart.symbol;
|
1618
1630
|
}
|
@@ -1793,7 +1805,7 @@ DateFormat.prototype.parse = function (sValue, bUTC, bStrict) {
|
|
1793
1805
|
if (bStrict === undefined) {
|
1794
1806
|
bStrict = this.oFormatOptions.strictParsing;
|
1795
1807
|
}
|
1796
|
-
if (sCalendarType
|
1808
|
+
if (sCalendarType === CalendarType.Japanese && this.oLocale.getLanguage() === 'ja') {
|
1797
1809
|
sValue = sValue.replace(/元年/g, '1年');
|
1798
1810
|
}
|
1799
1811
|
if (!this.oFormatOptions.interval) {
|
@@ -1830,7 +1842,7 @@ DateFormat.prototype.parse = function (sValue, bUTC, bStrict) {
|
|
1830
1842
|
} else {
|
1831
1843
|
var aDateValues = this._parseInterval(sValue, sCalendarType, bUTC, bStrict, sTimezone);
|
1832
1844
|
var oJSDate1, oJSDate2;
|
1833
|
-
if (aDateValues && aDateValues.length
|
1845
|
+
if (aDateValues && aDateValues.length === 2) {
|
1834
1846
|
var oDateValue1 = mergeWithoutOverwrite(aDateValues[0], aDateValues[1]);
|
1835
1847
|
var oDateValue2 = mergeWithoutOverwrite(aDateValues[1], aDateValues[0]);
|
1836
1848
|
oJSDate1 = fnCreateDate(oDateValue1, sCalendarType, bUTC, bStrict, sTimezone, this.oFormatOptions, this.oLocale);
|
@@ -1857,7 +1869,7 @@ DateFormat.prototype.parse = function (sValue, bUTC, bStrict) {
|
|
1857
1869
|
}
|
1858
1870
|
}
|
1859
1871
|
}
|
1860
|
-
if (
|
1872
|
+
if (this.aFallbackFormats) {
|
1861
1873
|
var vDate;
|
1862
1874
|
this.aFallbackFormats.every(function (oFallbackFormat) {
|
1863
1875
|
vDate = oFallbackFormat.parse(sValue, bUTCInputParameter, bStrict);
|
@@ -1889,20 +1901,20 @@ DateFormat.prototype.parseCldrDatePattern = function (sPattern) {
|
|
1889
1901
|
for (i = 0; i < sPattern.length; i++) {
|
1890
1902
|
var sCurChar = sPattern.charAt(i), sNextChar, sPrevChar, sPrevPrevChar;
|
1891
1903
|
if (bQuoted) {
|
1892
|
-
if (sCurChar
|
1904
|
+
if (sCurChar === '\'') {
|
1893
1905
|
sPrevChar = sPattern.charAt(i - 1);
|
1894
1906
|
sPrevPrevChar = sPattern.charAt(i - 2);
|
1895
1907
|
sNextChar = sPattern.charAt(i + 1);
|
1896
|
-
if (sPrevChar
|
1908
|
+
if (sPrevChar === '\'' && sPrevPrevChar !== '\'') {
|
1897
1909
|
bQuoted = false;
|
1898
|
-
} else if (sNextChar
|
1910
|
+
} else if (sNextChar === '\'') {
|
1899
1911
|
i += 1;
|
1900
1912
|
} else {
|
1901
1913
|
bQuoted = false;
|
1902
1914
|
continue;
|
1903
1915
|
}
|
1904
1916
|
}
|
1905
|
-
if (sState
|
1917
|
+
if (sState === 'text') {
|
1906
1918
|
oCurrentObject.value += sCurChar;
|
1907
1919
|
} else {
|
1908
1920
|
oCurrentObject = {
|
@@ -1913,11 +1925,11 @@ DateFormat.prototype.parseCldrDatePattern = function (sPattern) {
|
|
1913
1925
|
sState = 'text';
|
1914
1926
|
}
|
1915
1927
|
} else {
|
1916
|
-
if (sCurChar
|
1928
|
+
if (sCurChar === '\'') {
|
1917
1929
|
bQuoted = true;
|
1918
1930
|
} else if (this.oSymbols[sCurChar]) {
|
1919
1931
|
sNewState = this.oSymbols[sCurChar].name;
|
1920
|
-
if (sState
|
1932
|
+
if (sState === sNewState) {
|
1921
1933
|
oCurrentObject.digits++;
|
1922
1934
|
} else {
|
1923
1935
|
oCurrentObject = {
|
@@ -1937,7 +1949,7 @@ DateFormat.prototype.parseCldrDatePattern = function (sPattern) {
|
|
1937
1949
|
}
|
1938
1950
|
}
|
1939
1951
|
} else {
|
1940
|
-
if (sState
|
1952
|
+
if (sState === 'text') {
|
1941
1953
|
oCurrentObject.value += sCurChar;
|
1942
1954
|
} else {
|
1943
1955
|
oCurrentObject = {
|
@@ -1973,57 +1985,78 @@ DateFormat.prototype.parseRelative = function (sValue, bUTC) {
|
|
1973
1985
|
}
|
1974
1986
|
}
|
1975
1987
|
function computeRelativeDate(iDiff, sScale) {
|
1976
|
-
var
|
1977
|
-
if (bUTC) {
|
1978
|
-
iToday = oToday.getTime();
|
1979
|
-
} else {
|
1980
|
-
iToday = Date.UTC(oToday.getFullYear(), oToday.getMonth(), oToday.getDate(), oToday.getHours(), oToday.getMinutes(), oToday.getSeconds(), oToday.getMilliseconds());
|
1981
|
-
}
|
1982
|
-
oJSDate = new Date(iToday);
|
1983
|
-
switch (sScale) {
|
1984
|
-
case 'second':
|
1985
|
-
oJSDate.setUTCSeconds(oJSDate.getUTCSeconds() + iDiff);
|
1986
|
-
break;
|
1987
|
-
case 'minute':
|
1988
|
-
oJSDate.setUTCMinutes(oJSDate.getUTCMinutes() + iDiff);
|
1989
|
-
break;
|
1990
|
-
case 'hour':
|
1991
|
-
oJSDate.setUTCHours(oJSDate.getUTCHours() + iDiff);
|
1992
|
-
break;
|
1993
|
-
case 'day':
|
1994
|
-
oJSDate.setUTCDate(oJSDate.getUTCDate() + iDiff);
|
1995
|
-
break;
|
1996
|
-
case 'week':
|
1997
|
-
oJSDate.setUTCDate(oJSDate.getUTCDate() + iDiff * 7);
|
1998
|
-
break;
|
1999
|
-
case 'month':
|
2000
|
-
oJSDate.setUTCMonth(oJSDate.getUTCMonth() + iDiff);
|
2001
|
-
break;
|
2002
|
-
case 'quarter':
|
2003
|
-
oJSDate.setUTCMonth(oJSDate.getUTCMonth() + iDiff * 3);
|
2004
|
-
break;
|
2005
|
-
case 'year':
|
2006
|
-
oJSDate.setUTCFullYear(oJSDate.getUTCFullYear() + iDiff);
|
2007
|
-
break;
|
2008
|
-
}
|
1988
|
+
var oResult = UI5Date.getInstance();
|
2009
1989
|
if (bUTC) {
|
2010
|
-
|
1990
|
+
oResult.setUTCFullYear(oResult.getFullYear(), oResult.getMonth(), oResult.getDate());
|
1991
|
+
oResult.setUTCHours(oResult.getHours(), oResult.getMinutes(), oResult.getSeconds(), oResult.getMilliseconds());
|
1992
|
+
switch (sScale) {
|
1993
|
+
case 'second':
|
1994
|
+
oResult.setUTCSeconds(oResult.getUTCSeconds() + iDiff);
|
1995
|
+
break;
|
1996
|
+
case 'minute':
|
1997
|
+
oResult.setUTCMinutes(oResult.getUTCMinutes() + iDiff);
|
1998
|
+
break;
|
1999
|
+
case 'hour':
|
2000
|
+
oResult.setUTCHours(oResult.getUTCHours() + iDiff);
|
2001
|
+
break;
|
2002
|
+
case 'day':
|
2003
|
+
oResult.setUTCDate(oResult.getUTCDate() + iDiff);
|
2004
|
+
break;
|
2005
|
+
case 'week':
|
2006
|
+
oResult.setUTCDate(oResult.getUTCDate() + iDiff * 7);
|
2007
|
+
break;
|
2008
|
+
case 'month':
|
2009
|
+
oResult.setUTCMonth(oResult.getUTCMonth() + iDiff);
|
2010
|
+
break;
|
2011
|
+
case 'quarter':
|
2012
|
+
oResult.setUTCMonth(oResult.getUTCMonth() + iDiff * 3);
|
2013
|
+
break;
|
2014
|
+
case 'year':
|
2015
|
+
oResult.setUTCFullYear(oResult.getUTCFullYear() + iDiff);
|
2016
|
+
break;
|
2017
|
+
}
|
2011
2018
|
} else {
|
2012
|
-
|
2019
|
+
switch (sScale) {
|
2020
|
+
case 'second':
|
2021
|
+
oResult.setSeconds(oResult.getSeconds() + iDiff);
|
2022
|
+
break;
|
2023
|
+
case 'minute':
|
2024
|
+
oResult.setMinutes(oResult.getMinutes() + iDiff);
|
2025
|
+
break;
|
2026
|
+
case 'hour':
|
2027
|
+
oResult.setHours(oResult.getHours() + iDiff);
|
2028
|
+
break;
|
2029
|
+
case 'day':
|
2030
|
+
oResult.setDate(oResult.getDate() + iDiff);
|
2031
|
+
break;
|
2032
|
+
case 'week':
|
2033
|
+
oResult.setDate(oResult.getDate() + iDiff * 7);
|
2034
|
+
break;
|
2035
|
+
case 'month':
|
2036
|
+
oResult.setMonth(oResult.getMonth() + iDiff);
|
2037
|
+
break;
|
2038
|
+
case 'quarter':
|
2039
|
+
oResult.setMonth(oResult.getMonth() + iDiff * 3);
|
2040
|
+
break;
|
2041
|
+
case 'year':
|
2042
|
+
oResult.setFullYear(oResult.getFullYear() + iDiff);
|
2043
|
+
break;
|
2044
|
+
}
|
2013
2045
|
}
|
2046
|
+
return oResult;
|
2014
2047
|
}
|
2015
2048
|
};
|
2016
2049
|
DateFormat.prototype.formatRelative = function (oJSDate, bUTC, aRange, sTimezone) {
|
2017
|
-
var oToday = convertToTimezone(new Date(), sTimezone),
|
2050
|
+
var oDateUTC, iDiff, iDiffSeconds, sPattern, oToday = convertToTimezone(new Date(), sTimezone), sScale = this.oFormatOptions.relativeScale || 'day';
|
2018
2051
|
iDiffSeconds = (oJSDate.getTime() - oToday.getTime()) / 1000;
|
2019
|
-
if (this.oFormatOptions.relativeScale
|
2052
|
+
if (this.oFormatOptions.relativeScale === 'auto') {
|
2020
2053
|
sScale = this._getScale(iDiffSeconds, this.aRelativeScales);
|
2021
2054
|
sScale = fixScaleForMonths(oJSDate, oToday, sScale, iDiffSeconds);
|
2022
2055
|
}
|
2023
2056
|
if (!aRange) {
|
2024
2057
|
aRange = this._mRanges[sScale];
|
2025
2058
|
}
|
2026
|
-
if (sScale
|
2059
|
+
if (sScale === 'year' || sScale === 'month' || sScale === 'day') {
|
2027
2060
|
oToday = new Date(Date.UTC(oToday.getUTCFullYear(), oToday.getUTCMonth(), oToday.getUTCDate()));
|
2028
2061
|
oDateUTC = new Date(0);
|
2029
2062
|
oDateUTC.setUTCFullYear(oJSDate.getUTCFullYear(), oJSDate.getUTCMonth(), oJSDate.getUTCDate());
|
@@ -2033,7 +2066,7 @@ DateFormat.prototype.formatRelative = function (oJSDate, bUTC, aRange, sTimezone
|
|
2033
2066
|
oToday,
|
2034
2067
|
oJSDate
|
2035
2068
|
]);
|
2036
|
-
if (this.oFormatOptions.relativeScale
|
2069
|
+
if (this.oFormatOptions.relativeScale !== 'auto' && (iDiff < aRange[0] || iDiff > aRange[1])) {
|
2037
2070
|
return null;
|
2038
2071
|
}
|
2039
2072
|
sPattern = this.oLocaleData.getRelativePattern(sScale, iDiff, iDiffSeconds > 0, this.oFormatOptions.relativeStyle);
|
@@ -2110,7 +2143,7 @@ function fixScaleForMonths(oJSDate, oToday, sScale, iDiffSeconds) {
|
|
2110
2143
|
return sScale;
|
2111
2144
|
}
|
2112
2145
|
function cutDateFields(oDate, iStartIndex) {
|
2113
|
-
var aFields = [
|
2146
|
+
var sMethodName, aFields = [
|
2114
2147
|
'FullYear',
|
2115
2148
|
'Month',
|
2116
2149
|
'Date',
|
@@ -2118,8 +2151,7 @@ function cutDateFields(oDate, iStartIndex) {
|
|
2118
2151
|
'Minutes',
|
2119
2152
|
'Seconds',
|
2120
2153
|
'Milliseconds'
|
2121
|
-
],
|
2122
|
-
var oDateCopy = new Date(oDate.getTime());
|
2154
|
+
], oDateCopy = new Date(oDate.getTime());
|
2123
2155
|
for (var i = iStartIndex; i < aFields.length; i++) {
|
2124
2156
|
sMethodName = 'setUTC' + aFields[iStartIndex];
|
2125
2157
|
oDateCopy[sMethodName].apply(oDateCopy, [0]);
|
@@ -2233,4 +2265,28 @@ DateFormat.prototype.getAllowedCharacters = function (aFormatArray) {
|
|
2233
2265
|
}
|
2234
2266
|
return sAllowedCharacters;
|
2235
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
|
+
};
|
2236
2292
|
export default DateFormat;
|