@ui5/webcomponents-localization 2.20.0 → 2.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/generated/assets/cldr/Unicode-Data-Files-LICENSE.txt +36 -24
- package/dist/generated/assets/cldr/ar.json +624 -354
- package/dist/generated/assets/cldr/ar_EG.json +624 -354
- package/dist/generated/assets/cldr/ar_SA.json +625 -355
- package/dist/generated/assets/cldr/bg.json +339 -215
- package/dist/generated/assets/cldr/ca.json +633 -509
- package/dist/generated/assets/cldr/cnr.json +960 -653
- package/dist/generated/assets/cldr/cs.json +343 -531
- package/dist/generated/assets/cldr/cy.json +684 -1050
- package/dist/generated/assets/cldr/da.json +354 -231
- package/dist/generated/assets/cldr/de.json +458 -330
- package/dist/generated/assets/cldr/de_AT.json +459 -331
- package/dist/generated/assets/cldr/de_CH.json +522 -386
- package/dist/generated/assets/cldr/el.json +317 -152
- package/dist/generated/assets/cldr/el_CY.json +317 -152
- package/dist/generated/assets/cldr/en.json +606 -253
- package/dist/generated/assets/cldr/en_AU.json +830 -376
- package/dist/generated/assets/cldr/en_GB.json +696 -251
- package/dist/generated/assets/cldr/en_HK.json +544 -203
- package/dist/generated/assets/cldr/en_IE.json +533 -192
- package/dist/generated/assets/cldr/en_IN.json +820 -296
- package/dist/generated/assets/cldr/en_NZ.json +534 -193
- package/dist/generated/assets/cldr/en_PG.json +509 -168
- package/dist/generated/assets/cldr/en_SG.json +526 -185
- package/dist/generated/assets/cldr/en_ZA.json +529 -186
- package/dist/generated/assets/cldr/es.json +355 -230
- package/dist/generated/assets/cldr/es_AR.json +444 -288
- package/dist/generated/assets/cldr/es_BO.json +419 -264
- package/dist/generated/assets/cldr/es_CL.json +455 -300
- package/dist/generated/assets/cldr/es_CO.json +412 -257
- package/dist/generated/assets/cldr/es_MX.json +515 -352
- package/dist/generated/assets/cldr/es_PE.json +397 -234
- package/dist/generated/assets/cldr/es_UY.json +424 -269
- package/dist/generated/assets/cldr/es_VE.json +398 -243
- package/dist/generated/assets/cldr/et.json +390 -233
- package/dist/generated/assets/cldr/fa.json +510 -271
- package/dist/generated/assets/cldr/fi.json +497 -251
- package/dist/generated/assets/cldr/fr.json +339 -106
- package/dist/generated/assets/cldr/fr_BE.json +341 -108
- package/dist/generated/assets/cldr/fr_CA.json +652 -397
- package/dist/generated/assets/cldr/fr_CH.json +342 -109
- package/dist/generated/assets/cldr/fr_LU.json +339 -106
- package/dist/generated/assets/cldr/he.json +726 -904
- package/dist/generated/assets/cldr/hi.json +529 -288
- package/dist/generated/assets/cldr/hr.json +392 -383
- package/dist/generated/assets/cldr/hu.json +459 -335
- package/dist/generated/assets/cldr/id.json +379 -128
- package/dist/generated/assets/cldr/it.json +420 -301
- package/dist/generated/assets/cldr/it_CH.json +426 -307
- package/dist/generated/assets/cldr/ja.json +332 -74
- package/dist/generated/assets/cldr/kk.json +540 -240
- package/dist/generated/assets/cldr/ko.json +371 -115
- package/dist/generated/assets/cldr/lt.json +428 -545
- package/dist/generated/assets/cldr/lv.json +415 -413
- package/dist/generated/assets/cldr/mk.json +691 -559
- package/dist/generated/assets/cldr/ms.json +395 -136
- package/dist/generated/assets/cldr/nb.json +355 -234
- package/dist/generated/assets/cldr/nl.json +357 -251
- package/dist/generated/assets/cldr/nl_BE.json +428 -322
- package/dist/generated/assets/cldr/pl.json +333 -459
- package/dist/generated/assets/cldr/pt.json +419 -298
- package/dist/generated/assets/cldr/pt_PT.json +362 -231
- package/dist/generated/assets/cldr/ro.json +369 -397
- package/dist/generated/assets/cldr/ru.json +599 -368
- package/dist/generated/assets/cldr/ru_UA.json +598 -367
- package/dist/generated/assets/cldr/sk.json +343 -517
- package/dist/generated/assets/cldr/sl.json +477 -640
- package/dist/generated/assets/cldr/sr.json +478 -531
- package/dist/generated/assets/cldr/sr_Latn.json +631 -684
- package/dist/generated/assets/cldr/sv.json +395 -258
- package/dist/generated/assets/cldr/th.json +452 -199
- package/dist/generated/assets/cldr/tr.json +391 -238
- package/dist/generated/assets/cldr/uk.json +696 -342
- package/dist/generated/assets/cldr/vi.json +836 -487
- package/dist/generated/assets/cldr/zh_CN.json +358 -104
- package/dist/generated/assets/cldr/zh_HK.json +366 -113
- package/dist/generated/assets/cldr/zh_SG.json +371 -118
- package/dist/generated/assets/cldr/zh_TW.json +480 -238
- package/dist/sap/base/Event.js +2 -2
- package/dist/sap/base/Eventing.js +4 -3
- package/dist/sap/base/assert.js +1 -1
- package/dist/sap/base/config/MemoryConfigurationProvider.js +1 -1
- package/dist/sap/base/future.js +12 -0
- package/dist/sap/base/i18n/Formatting.d.ts +5 -0
- package/dist/sap/base/i18n/Formatting.js +7 -0
- package/dist/sap/base/i18n/Formatting.js.map +1 -1
- package/dist/sap/base/i18n/LanguageTag.js +18 -12
- package/dist/sap/base/i18n/Localization.d.ts +3 -0
- package/dist/sap/base/i18n/Localization.js +5 -0
- package/dist/sap/base/i18n/Localization.js.map +1 -1
- package/dist/sap/base/i18n/ResourceBundle.js +20 -0
- package/dist/sap/base/i18n/date/CalendarType.js +9 -8
- package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +9 -8
- package/dist/sap/base/i18n/date/TimezoneUtils.js +170 -18
- package/dist/sap/base/i18n/date/_EnumHelper.js +37 -0
- package/dist/sap/base/strings/camelize.js +1 -1
- package/dist/sap/base/strings/formatMessage.js +6 -1
- package/dist/sap/base/util/Properties.js +12 -0
- package/dist/sap/base/util/Version.js +19 -13
- package/dist/sap/base/util/_merge.js +1 -1
- package/dist/sap/base/util/array/uniqueSort.js +1 -1
- package/dist/sap/base/util/deepClone.js +2 -2
- package/dist/sap/base/util/deepEqual.js +1 -1
- package/dist/sap/base/util/deepExtend.js +60 -0
- package/dist/sap/base/util/extend.js +1 -1
- package/dist/sap/base/util/fetch.js +8 -0
- package/dist/sap/base/util/isEmptyObject.js +1 -1
- package/dist/sap/base/util/isPlainObject.js +1 -1
- package/dist/sap/base/util/merge.js +57 -0
- package/dist/sap/base/util/mixedFetch.js +3 -0
- package/dist/sap/base/util/now.js +7 -13
- package/dist/sap/base/util/uid.js +1 -1
- package/dist/sap/ui/Device.js +27 -0
- package/dist/sap/ui/Global.js +1 -0
- package/dist/sap/ui/VersionInfo.js +14 -0
- package/dist/sap/ui/base/DataType.js +63 -12
- package/dist/sap/ui/base/DesignTime.js +11 -0
- package/dist/sap/ui/base/EventProvider.js +21 -0
- package/dist/sap/ui/base/Metadata.js +45 -10
- package/dist/sap/ui/base/Object.js +2 -2
- package/dist/sap/ui/base/OwnStatics.js +6 -0
- package/dist/sap/ui/base/SyncPromise.js +98 -0
- package/dist/sap/ui/core/AnimationMode.js +42 -0
- package/dist/sap/ui/core/CalendarType.js +2 -2
- package/dist/sap/ui/core/ControlBehavior.js +11 -0
- package/dist/sap/ui/core/Lib.js +41 -0
- package/dist/sap/ui/core/Locale.js +9 -9
- package/dist/sap/ui/core/LocaleData.js +498 -333
- package/dist/sap/ui/core/Theming.js +25 -525
- package/dist/sap/ui/core/_UrlResolver.js +11 -0
- package/dist/sap/ui/core/date/Buddhist.js +2 -2
- package/dist/sap/ui/core/date/CalendarUtils.js +14 -12
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +2 -2
- package/dist/sap/ui/core/date/Gregorian.js +2 -2
- package/dist/sap/ui/core/date/Islamic.js +2 -2
- package/dist/sap/ui/core/date/Japanese.js +2 -2
- package/dist/sap/ui/core/date/Persian.js +2 -2
- package/dist/sap/ui/core/date/UI5Date.js +80 -32
- package/dist/sap/ui/core/date/UniversalDate.js +83 -101
- package/dist/sap/ui/core/format/DateFormat.js +70 -73
- package/dist/sap/ui/core/format/FormatUtils.js +30 -0
- package/dist/sap/ui/core/format/NumberFormat.js +917 -588
- package/dist/sap/ui/core/format/TimezoneUtil.js +80 -11
- package/dist/sap/ui/core/getCompatibilityVersion.js +7 -0
- package/dist/sap/ui/core/theming/ThemeHelper.js +14 -0
- package/dist/sap/ui/security/Security.js +12 -0
- package/dist/sap/ui/util/XMLHelper.js +11 -0
- package/dist/sap/ui/util/_URL.js +1 -0
- package/dist/ui5loader-autoconfig.js +1 -0
- package/package.json +5 -5
- package/used-modules.txt +5 -0
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* OpenUI5
|
|
3
|
-
* (c) Copyright
|
|
3
|
+
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
5
5
|
*/
|
|
6
6
|
// Provides class sap.ui.core.format.DateFormat
|
|
7
7
|
import Log from "../../../base/Log.js";
|
|
8
|
+
import Formatting from "../../../base/i18n/Formatting.js";
|
|
9
|
+
import Localization from "../../../base/i18n/Localization.js";
|
|
10
|
+
import CalendarType from "../../../base/i18n/date/CalendarType.js";
|
|
11
|
+
import CalendarWeekNumbering from "../../../base/i18n/date/CalendarWeekNumbering.js";
|
|
12
|
+
import TimezoneUtils from "../../../base/i18n/date/TimezoneUtils.js";
|
|
8
13
|
import formatMessage from "../../../base/strings/formatMessage.js";
|
|
9
14
|
import deepEqual from "../../../base/util/deepEqual.js";
|
|
10
15
|
import extend from "../../../base/util/extend.js";
|
|
11
|
-
import
|
|
12
|
-
import Configuration from "../Configuration.js";
|
|
13
|
-
import Core from "../Core.js";
|
|
16
|
+
import Library from "../Lib.js";
|
|
14
17
|
import Locale from "../Locale.js";
|
|
15
18
|
import LocaleData from "../LocaleData.js";
|
|
16
19
|
import Supportability from "../Supportability.js";
|
|
17
20
|
import CalendarUtils from "../date/CalendarUtils.js";
|
|
18
|
-
import CalendarWeekNumbering from "../date/CalendarWeekNumbering.js";
|
|
19
21
|
import UI5Date from "../date/UI5Date.js";
|
|
20
22
|
import UniversalDate from "../date/UniversalDate.js";
|
|
21
|
-
import
|
|
23
|
+
import FormatUtils from "./FormatUtils.js";
|
|
22
24
|
/**
|
|
23
25
|
* Constructor for DateFormat - must not be used:
|
|
24
26
|
* <ul>
|
|
@@ -31,7 +33,8 @@ import TimezoneUtil from "./TimezoneUtil.js";
|
|
|
31
33
|
* to a set of format options.
|
|
32
34
|
*
|
|
33
35
|
* Important:
|
|
34
|
-
* Every Date is converted with the timezone taken from
|
|
36
|
+
* Every Date is converted with the timezone taken from
|
|
37
|
+
* {@link module:sap/base/i18n/Localization.getTimezone Localization.getTimezone}.
|
|
35
38
|
* The timezone falls back to the browser's local timezone.
|
|
36
39
|
*
|
|
37
40
|
* Supported format options are pattern based on Unicode LDML Date Format notation. Please note that only a subset of the LDML date symbols
|
|
@@ -234,13 +237,14 @@ DateFormat.getInstance = function (oFormatOptions, oLocale) {
|
|
|
234
237
|
* Get a date instance of the DateFormat, which can be used for formatting.
|
|
235
238
|
*
|
|
236
239
|
* @param {object} [oFormatOptions] Object which defines the format options
|
|
237
|
-
* @param {sap
|
|
240
|
+
* @param {module:sap/base/i18n/date/CalendarWeekNumbering} [oFormatOptions.calendarWeekNumbering] since 1.108.0 specifies the calendar week numbering.
|
|
238
241
|
* If specified, this overwrites <code>oFormatOptions.firstDayOfWeek</code> and <code>oFormatOptions.minimalDaysInFirstWeek</code>.
|
|
239
242
|
* @param {int} [oFormatOptions.firstDayOfWeek] since 1.105.0 specifies the first day of the week starting with <code>0</code> (which is Sunday); if not defined, the value taken from the locale is used
|
|
240
243
|
* @param {int} [oFormatOptions.minimalDaysInFirstWeek] since 1.105.0 minimal days at the beginning of the year which define the first calendar week; if not defined, the value taken from the locale is used
|
|
241
244
|
* @param {string} [oFormatOptions.format] since 1.34.0 contains pattern symbols (e.g. "yMMMd" or "Hms") which will be converted into the pattern in the used locale, which matches the wanted symbols best.
|
|
242
245
|
* The symbols must be in canonical order, that is: Era (G), Year (y/Y), Quarter (q/Q), Month (M/L), Week (w), Day-Of-Week (E/e/c), Day (d), Hour (h/H/k/K/j/J), Minute (m), Second (s), Timezone (z/Z/v/V/O/X/x)
|
|
243
|
-
* See {@link
|
|
246
|
+
* See {@link https://unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems
|
|
247
|
+
* Unicode Locale Data Markup Language (LDML): Elements availableFormats, appendItems}.
|
|
244
248
|
* @param {string} [oFormatOptions.pattern] a data pattern in LDML format. It is not verified whether the pattern represents only a date.
|
|
245
249
|
* @param {string} [oFormatOptions.style] can be either 'short, 'medium', 'long' or 'full'. If no pattern is given, a locale dependent default date pattern of that style is used from the LocaleData class.
|
|
246
250
|
* @param {boolean} [oFormatOptions.strictParsing] if true, by parsing it is checked if the value is a valid date
|
|
@@ -258,7 +262,7 @@ DateFormat.getInstance = function (oFormatOptions, oLocale) {
|
|
|
258
262
|
* "Jan 10 – Feb 12, 2008" becomes "Jan 10, 2008...Feb 12, 2008".
|
|
259
263
|
* @param {boolean} [oFormatOptions.singleIntervalValue=false] Only relevant if oFormatOptions.interval is set to 'true'. This allows to pass an array with only one date object to the {@link sap.ui.core.format.DateFormat#format format} method.
|
|
260
264
|
* @param {boolean} [oFormatOptions.UTC] if true, the date is formatted and parsed as UTC instead of the local timezone
|
|
261
|
-
* @param {sap
|
|
265
|
+
* @param {module:sap/base/i18n/date/CalendarType} [oFormatOptions.calendarType] The calender type which is used to format and parse the date. This value is by default either set in configuration or calculated based on current locale.
|
|
262
266
|
* @param {sap.ui.core.Locale} [oLocale] Locale to ask for locale specific texts/settings
|
|
263
267
|
* @ui5-omissible-params oFormatOptions
|
|
264
268
|
* @return {sap.ui.core.format.DateFormat} date instance of the DateFormat
|
|
@@ -278,19 +282,20 @@ DateFormat.getDateInstance = function (oFormatOptions, oLocale) {
|
|
|
278
282
|
* Get a datetime instance of the DateFormat, which can be used for formatting.
|
|
279
283
|
*
|
|
280
284
|
* @param {object} [oFormatOptions] Object which defines the format options
|
|
281
|
-
* @param {sap
|
|
285
|
+
* @param {module:sap/base/i18n/date/CalendarWeekNumbering} [oFormatOptions.calendarWeekNumbering] since 1.108.0 specifies the calendar week numbering.
|
|
282
286
|
* If specified, this overwrites <code>oFormatOptions.firstDayOfWeek</code> and <code>oFormatOptions.minimalDaysInFirstWeek</code>.
|
|
283
287
|
* @param {int} [oFormatOptions.firstDayOfWeek] since 1.105.0 specifies the first day of the week starting with <code>0</code> (which is Sunday); if not defined, the value taken from the locale is used
|
|
284
288
|
* @param {int} [oFormatOptions.minimalDaysInFirstWeek] since 1.105.0 minimal days at the beginning of the year which define the first calendar week; if not defined, the value taken from the locale is used
|
|
285
289
|
* @param {string} [oFormatOptions.format] since 1.34.0 contains pattern symbols (e.g. "yMMMd" or "Hms") which will be converted into the pattern in the used locale, which matches the wanted symbols best.
|
|
286
290
|
* The symbols must be in canonical order, that is: Era (G), Year (y/Y), Quarter (q/Q), Month (M/L), Week (w), Day-Of-Week (E/e/c), Day (d), Hour (h/H/k/K/j/J), Minute (m), Second (s), Timezone (z/Z/v/V/O/X/x)
|
|
287
|
-
* See
|
|
291
|
+
* See {@link https://unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems
|
|
292
|
+
* Unicode Locale Data Markup Language (LDML): Elements availableFormats, appendItems}.
|
|
288
293
|
* @param {string} [oFormatOptions.pattern] a datetime pattern in LDML format. It is not verified whether the pattern represents a full datetime.
|
|
289
294
|
* @param {string} [oFormatOptions.style] can be either 'short, 'medium', 'long' or 'full'. For datetime you can also define mixed styles, separated with a slash, where the first part is the date style and the second part is the time style (e.g. "medium/short"). If no pattern is given, a locale dependent default datetime pattern of that style is used from the LocaleData class.
|
|
290
295
|
* @param {boolean} [oFormatOptions.strictParsing] if true, by parsing it is checked if the value is a valid datetime
|
|
291
296
|
* @param {boolean} [oFormatOptions.relative] if true, the date is formatted relatively to today's date if it is within the given day range, e.g. "today", "1 day ago", "in 5 days"
|
|
292
|
-
* @param {int[]} [oFormatOptions.relativeRange] the day range used for relative formatting. If <code>oFormatOptions.relativeScale</code> is set to
|
|
293
|
-
* @param {string} [oFormatOptions.relativeScale="
|
|
297
|
+
* @param {int[]} [oFormatOptions.relativeRange] the day range used for relative formatting. If <code>oFormatOptions.relativeScale</code> is set to value 'day', the relativeRange is by default [-6, 6], which means only the last 6 days, today and the next 6 days are formatted relatively. Otherwise when <code>oFormatOptions.relativeScale</code> is set to 'auto', all dates are formatted relatively.
|
|
298
|
+
* @param {string} [oFormatOptions.relativeScale="auto"] if 'auto' is set, new relative time format is switched on for all Date/Time Instances. The relative scale is chosen depending on the difference between the given date and now.
|
|
294
299
|
* @param {string} [oFormatOptions.relativeStyle="wide"] since 1.32.10, 1.34.4 the style of the relative format. The valid values are "wide", "short", "narrow"
|
|
295
300
|
* @param {boolean} [oFormatOptions.interval=false] since 1.48.0 if true, the {@link sap.ui.core.format.DateFormat#format format} method expects an array with two dates as the first argument and formats them as interval. Further interval "Jan 10, 2008 - Jan 12, 2008" will be formatted as "Jan 10-12, 2008" if the 'format' option is set with necessary symbols.
|
|
296
301
|
* Otherwise the two given dates are formatted separately and concatenated with local dependent pattern.
|
|
@@ -302,7 +307,7 @@ DateFormat.getDateInstance = function (oFormatOptions, oLocale) {
|
|
|
302
307
|
* "Jan 10, 2008, 9:15 – 11:45 AM" becomes "Jan 10, 2008, 9:15 AM...Jan 10, 2008, 11:45 AM".
|
|
303
308
|
* @param {boolean} [oFormatOptions.singleIntervalValue=false] Only relevant if oFormatOptions.interval is set to 'true'. This allows to pass an array with only one date object to the {@link sap.ui.core.format.DateFormat#format format} method.
|
|
304
309
|
* @param {boolean} [oFormatOptions.UTC] if true, the date is formatted and parsed as UTC instead of the local timezone
|
|
305
|
-
* @param {sap
|
|
310
|
+
* @param {module:sap/base/i18n/date/CalendarType} [oFormatOptions.calendarType] The calender type which is used to format and parse the date. This value is by default either set in configuration or calculated based on current locale.
|
|
306
311
|
* @param {sap.ui.core.Locale} [oLocale] Locale to ask for locale specific texts/settings
|
|
307
312
|
* @ui5-omissible-params oFormatOptions
|
|
308
313
|
* @return {sap.ui.core.format.DateFormat} datetime instance of the DateFormat
|
|
@@ -354,10 +359,12 @@ DateFormat.getDateTimeInstance = function (oFormatOptions, oLocale) {
|
|
|
354
359
|
* DateFormat.getDateTimeWithTimezoneInstance({showDate: false, showTime: false}).format(oDate, "America/New_York");
|
|
355
360
|
* // output: "Americas, New York"
|
|
356
361
|
*
|
|
357
|
-
* @param {Date} oJSDate The date to format
|
|
362
|
+
* @param {Date} [oJSDate] The date to format. If it is <code>null</code> or <code>undefined</code> only the
|
|
363
|
+
* timezone will be formatted, any other invalid date is formatted as empty string.
|
|
358
364
|
* @param {string} [sTimezone] The IANA timezone ID in which the date will be calculated and
|
|
359
|
-
* formatted e.g. "America/New_York". If the parameter is omitted, <code>null</code> or an empty string, the
|
|
360
|
-
* will be taken from {@link sap.
|
|
365
|
+
* formatted e.g. "America/New_York". If the parameter is omitted, <code>null</code> or an empty string, the
|
|
366
|
+
* timezone will be taken from {@link module:sap/base/i18n/Localization.getTimezone Localization.getTimezone}.
|
|
367
|
+
* For an invalid IANA time zone ID, an empty string will be returned.
|
|
361
368
|
* @throws {TypeError} Thrown if the parameter <code>sTimezone</code> is provided and has the wrong type.
|
|
362
369
|
* @return {string} the formatted output value. If an invalid date or timezone is given, an empty string is returned.
|
|
363
370
|
* @name sap.ui.core.format.DateFormat.DateTimeWithTimezone.format
|
|
@@ -390,8 +397,9 @@ DateFormat.getDateTimeInstance = function (oFormatOptions, oLocale) {
|
|
|
390
397
|
*
|
|
391
398
|
* @param {string} sValue the string containing a formatted date/time value
|
|
392
399
|
* @param {string} [sTimezone] The IANA timezone ID which should be used to convert the date
|
|
393
|
-
* e.g. "America/New_York". If the parameter is omitted, <code>null</code> or an empty string, the timezone will
|
|
394
|
-
* from {@link sap.
|
|
400
|
+
* e.g. "America/New_York". If the parameter is omitted, <code>null</code> or an empty string, the timezone will
|
|
401
|
+
* be taken from {@link module:sap/base/i18n/Localization.getTimezone Localization.getTimezone}. For an invalid
|
|
402
|
+
* IANA timezone ID, <code>null</code> will be returned.
|
|
395
403
|
* @param {boolean} [bStrict] Whether to be strict with regards to the value ranges of date fields,
|
|
396
404
|
* e.g. for a month pattern of <code>MM</code> and a value range of [1-12]
|
|
397
405
|
* <code>strict</code> ensures that the value is within the range;
|
|
@@ -428,13 +436,14 @@ DateFormat.getDateTimeInstance = function (oFormatOptions, oLocale) {
|
|
|
428
436
|
* Get a datetimeWithTimezone instance of the DateFormat, which can be used for formatting.
|
|
429
437
|
*
|
|
430
438
|
* @param {object} [oFormatOptions] An object which defines the format options
|
|
431
|
-
* @param {sap
|
|
439
|
+
* @param {module:sap/base/i18n/date/CalendarWeekNumbering} [oFormatOptions.calendarWeekNumbering] since 1.108.0 specifies the calendar week numbering.
|
|
432
440
|
* If specified, this overwrites <code>oFormatOptions.firstDayOfWeek</code> and <code>oFormatOptions.minimalDaysInFirstWeek</code>.
|
|
433
441
|
* @param {int} [oFormatOptions.firstDayOfWeek] since 1.105.0 specifies the first day of the week starting with <code>0</code> (which is Sunday); if not defined, the value taken from the locale is used
|
|
434
442
|
* @param {int} [oFormatOptions.minimalDaysInFirstWeek] since 1.105.0 minimal days at the beginning of the year which define the first calendar week; if not defined, the value taken from the locale is used
|
|
435
443
|
* @param {string} [oFormatOptions.format] A string containing pattern symbols (e.g. "yMMMd" or "Hms") which will be converted into a pattern for the used locale that matches the wanted symbols best.
|
|
436
444
|
* The symbols must be in canonical order, that is: Era (G), Year (y/Y), Quarter (q/Q), Month (M/L), Week (w), Day-Of-Week (E/e/c), Day (d), Hour (h/H/k/K/j/J), Minute (m), Second (s), Timezone (z/Z/v/V/O/X/x)
|
|
437
|
-
* See
|
|
445
|
+
* See {@link https://unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems
|
|
446
|
+
* Unicode Locale Data Markup Language (LDML): Elements availableFormats, appendItems}.
|
|
438
447
|
* @param {string} [oFormatOptions.pattern] a datetime pattern in LDML format. It is not verified whether the pattern represents a full datetime.
|
|
439
448
|
* @param {boolean} [oFormatOptions.showDate=true] Specifies if the date should be displayed.
|
|
440
449
|
* It is ignored for formatting when an options pattern or a format are supplied.
|
|
@@ -448,7 +457,7 @@ DateFormat.getDateTimeInstance = function (oFormatOptions, oLocale) {
|
|
|
448
457
|
* @param {int[]} [oFormatOptions.relativeRange] The day range used for relative formatting. If <code>oFormatOptions.relativeScale</code> is set to the default value 'day', the <code>relativeRange<code> is by default [-6, 6], which means that only the previous 6 and the following 6 days are formatted relatively. If <code>oFormatOptions.relativeScale</code> is set to 'auto', all dates are formatted relatively.
|
|
449
458
|
* @param {string} [oFormatOptions.relativeScale] If 'auto' is set, a new relative time format is switched on for all Date/Time instances. The default value depends on <code>showDate</code> and <code>showTime</code> options.
|
|
450
459
|
* @param {string} [oFormatOptions.relativeStyle="wide"] The style of the relative format. The valid values are "wide", "short", "narrow"
|
|
451
|
-
* @param {sap
|
|
460
|
+
* @param {module:sap/base/i18n/date/CalendarType} [oFormatOptions.calendarType] The calendar type which is used to format and parse the date. This value is by default either set in the configuration or calculated based on the current locale.
|
|
452
461
|
* @param {sap.ui.core.Locale} [oLocale] Locale to ask for locale-specific texts/settings
|
|
453
462
|
* @ui5-omissible-params oFormatOptions
|
|
454
463
|
* @throws {TypeError} If an invalid configuration was supplied, i.e. when the
|
|
@@ -495,19 +504,20 @@ DateFormat.getDateTimeWithTimezoneInstance = function (oFormatOptions, oLocale)
|
|
|
495
504
|
* Get a time instance of the DateFormat, which can be used for formatting.
|
|
496
505
|
*
|
|
497
506
|
* @param {object} [oFormatOptions] Object which defines the format options
|
|
498
|
-
* @param {sap
|
|
507
|
+
* @param {module:sap/base/i18n/date/CalendarWeekNumbering} [oFormatOptions.calendarWeekNumbering] since 1.108.0 specifies the calendar week numbering.
|
|
499
508
|
* If specified, this overwrites <code>oFormatOptions.firstDayOfWeek</code> and <code>oFormatOptions.minimalDaysInFirstWeek</code>.
|
|
500
509
|
* @param {int} [oFormatOptions.firstDayOfWeek] since 1.105.0 specifies the first day of the week starting with <code>0</code> (which is Sunday); if not defined, the value taken from the locale is used
|
|
501
510
|
* @param {int} [oFormatOptions.minimalDaysInFirstWeek] since 1.105.0 minimal days at the beginning of the year which define the first calendar week; if not defined, the value taken from the locale is used
|
|
502
511
|
* @param {string} [oFormatOptions.format] since 1.34.0 contains pattern symbols (e.g. "yMMMd" or "Hms") which will be converted into the pattern in the used locale, which matches the wanted symbols best.
|
|
503
512
|
* The symbols must be in canonical order, that is: Era (G), Year (y/Y), Quarter (q/Q), Month (M/L), Week (w), Day-Of-Week (E/e/c), Day (d), Hour (h/H/k/K/j/J), Minute (m), Second (s), Timezone (z/Z/v/V/O/X/x)
|
|
504
|
-
* See
|
|
513
|
+
* See {@link https://unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems
|
|
514
|
+
* Unicode Locale Data Markup Language (LDML): Elements availableFormats, appendItems}.
|
|
505
515
|
* @param {string} [oFormatOptions.pattern] a time pattern in LDML format. It is not verified whether the pattern only represents a time.
|
|
506
516
|
* @param {string} [oFormatOptions.style] can be either 'short, 'medium', 'long' or 'full'. If no pattern is given, a locale dependent default time pattern of that style is used from the LocaleData class.
|
|
507
517
|
* @param {boolean} [oFormatOptions.strictParsing] if true, by parsing it is checked if the value is a valid time
|
|
508
518
|
* @param {boolean} [oFormatOptions.relative] if true, the date is formatted relatively to todays date if it is within the given day range, e.g. "today", "1 day ago", "in 5 days"
|
|
509
|
-
* @param {int[]} [oFormatOptions.relativeRange] the day range used for relative formatting. If <code>oFormatOptions.relativeScale</code> is set to
|
|
510
|
-
* @param {string} [oFormatOptions.relativeScale="
|
|
519
|
+
* @param {int[]} [oFormatOptions.relativeRange] the day range used for relative formatting. If <code>oFormatOptions.relativeScale</code> is set to value 'day', the relativeRange is by default [-6, 6], which means only the last 6 days, today and the next 6 days are formatted relatively. Otherwise when <code>oFormatOptions.relativeScale</code> is set to 'auto', all dates are formatted relatively.
|
|
520
|
+
* @param {string} [oFormatOptions.relativeScale="auto"] if 'auto' is set, new relative time format is switched on for all Date/Time Instances. The relative scale is chosen depending on the difference between the given date and now.
|
|
511
521
|
* @param {string} [oFormatOptions.relativeStyle="wide"] since 1.32.10, 1.34.4 the style of the relative format. The valid values are "wide", "short", "narrow"
|
|
512
522
|
* @param {boolean} [oFormatOptions.interval=false] since 1.48.0 if true, the {@link sap.ui.core.format.DateFormat#format format} method expects an array with two dates as the first argument and formats them as interval. Further interval "Jan 10, 2008 - Jan 12, 2008" will be formatted as "Jan 10-12, 2008" if the 'format' option is set with necessary symbols.
|
|
513
523
|
* Otherwise the two given dates are formatted separately and concatenated with local dependent pattern.
|
|
@@ -519,7 +529,7 @@ DateFormat.getDateTimeWithTimezoneInstance = function (oFormatOptions, oLocale)
|
|
|
519
529
|
* "09:15 – 11:45 AM" becomes "9:15 AM...11:45 AM".
|
|
520
530
|
* @param {boolean} [oFormatOptions.singleIntervalValue=false] Only relevant if oFormatOptions.interval is set to 'true'. This allows to pass an array with only one date object to the {@link sap.ui.core.format.DateFormat#format format} method.
|
|
521
531
|
* @param {boolean} [oFormatOptions.UTC] if true, the time is formatted and parsed as UTC instead of the local timezone
|
|
522
|
-
* @param {sap
|
|
532
|
+
* @param {module:sap/base/i18n/date/CalendarType} [oFormatOptions.calendarType] The calender type which is used to format and parse the date. This value is by default either set in configuration or calculated based on current locale.
|
|
523
533
|
* @param {sap.ui.core.Locale} [oLocale] Locale to ask for locale specific texts/settings
|
|
524
534
|
* @ui5-omissible-params oFormatOptions
|
|
525
535
|
* @return {sap.ui.core.format.DateFormat} time instance of the DateFormat
|
|
@@ -566,7 +576,7 @@ DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo, bIsFallbac
|
|
|
566
576
|
|
|
567
577
|
// Get Locale and LocaleData to use
|
|
568
578
|
if (!oLocale) {
|
|
569
|
-
oLocale =
|
|
579
|
+
oLocale = new Locale(Formatting.getLanguageTag());
|
|
570
580
|
}
|
|
571
581
|
oFormat.oLocale = oLocale;
|
|
572
582
|
oFormat.oLocaleData = LocaleData.getInstance(oLocale);
|
|
@@ -589,7 +599,7 @@ DateFormat.createInstance = function (oFormatOptions, oLocale, oInfo, bIsFallbac
|
|
|
589
599
|
// type cannot be changed and should be an instance property instead of a format option
|
|
590
600
|
oFormat.type = oInfo.type;
|
|
591
601
|
if (!oFormat.oFormatOptions.calendarType) {
|
|
592
|
-
oFormat.oFormatOptions.calendarType =
|
|
602
|
+
oFormat.oFormatOptions.calendarType = Formatting.getCalendarType();
|
|
593
603
|
}
|
|
594
604
|
if (oFormat.oFormatOptions.firstDayOfWeek === undefined && oFormat.oFormatOptions.minimalDaysInFirstWeek !== undefined || oFormat.oFormatOptions.firstDayOfWeek !== undefined && oFormat.oFormatOptions.minimalDaysInFirstWeek === undefined) {
|
|
595
605
|
throw new TypeError("Format options firstDayOfWeek and minimalDaysInFirstWeek need both to be set, but only one was provided.");
|
|
@@ -721,11 +731,11 @@ DateFormat.prototype.init = function () {
|
|
|
721
731
|
* instances are used as fallback formats of another DateFormat instances.
|
|
722
732
|
*
|
|
723
733
|
* @param {Object[]} aFallbackFormatOptions the options for creating the fallback DateFormat
|
|
724
|
-
* @param {sap
|
|
734
|
+
* @param {module:sap/base/i18n/date/CalendarType} sCalendarType the type of the current calendarType
|
|
725
735
|
* @param {sap.ui.core.Locale} oLocale Locale to ask for locale specific texts/settings
|
|
726
736
|
* @param {Object} oInfo The default info object of the current date type
|
|
727
737
|
* @param {object} oParentFormatOptions the format options, relevant are: interval, showDate, showTime and showTimezone
|
|
728
|
-
* @return {sap.ui.core.DateFormat[]} an array of fallback DateFormat instances
|
|
738
|
+
* @return {sap.ui.core.format.DateFormat[]} an array of fallback DateFormat instances
|
|
729
739
|
* @private
|
|
730
740
|
*/
|
|
731
741
|
DateFormat._createFallbackFormat = function (aFallbackFormatOptions, sCalendarType, oLocale, oInfo, oParentFormatOptions) {
|
|
@@ -1055,7 +1065,7 @@ DateFormat.prototype.oSymbols = {
|
|
|
1055
1065
|
// If the current letter in the pattern is " ", sValue is allowed to have no match, exact match
|
|
1056
1066
|
// or multiple " ". This makes the parsing more tolerant. Special spaces or RTL characters have
|
|
1057
1067
|
// to be normalized before comparison.
|
|
1058
|
-
const sPartValue =
|
|
1068
|
+
const sPartValue = FormatUtils.normalize(oPart.value);
|
|
1059
1069
|
for (; iPatternIndex < sPartValue.length; iPatternIndex++) {
|
|
1060
1070
|
sChar = sPartValue.charAt(iPatternIndex);
|
|
1061
1071
|
if (sChar === " ") {
|
|
@@ -1702,7 +1712,7 @@ DateFormat.prototype.oSymbols = {
|
|
|
1702
1712
|
}
|
|
1703
1713
|
for (i = 0; i < aDayPeriodsVariants.length; i += 1) {
|
|
1704
1714
|
aVariants = aDayPeriodsVariants[i].map(sDayPeriod => {
|
|
1705
|
-
return
|
|
1715
|
+
return FormatUtils.normalize(sDayPeriod);
|
|
1706
1716
|
});
|
|
1707
1717
|
if (bAMPMAlternativeCase) {
|
|
1708
1718
|
// check normalized match for alternative case of am/pm
|
|
@@ -2005,7 +2015,7 @@ DateFormat.prototype.oSymbols = {
|
|
|
2005
2015
|
}
|
|
2006
2016
|
|
|
2007
2017
|
// valid for zzzz (fallback to OOOO)
|
|
2008
|
-
var iTimezoneOffset =
|
|
2018
|
+
var iTimezoneOffset = TimezoneUtils.calculateOffset(oDate, sTimezone);
|
|
2009
2019
|
var sTimeZone = "GMT";
|
|
2010
2020
|
var iTZOffset = Math.abs(iTimezoneOffset / 60);
|
|
2011
2021
|
var bPositiveOffset = iTimezoneOffset > 0;
|
|
@@ -2051,7 +2061,7 @@ DateFormat.prototype.oSymbols = {
|
|
|
2051
2061
|
"Z": DateFormat._createPatternSymbol({
|
|
2052
2062
|
name: "timezoneRFC822",
|
|
2053
2063
|
format: function (oField, oDate, bUTC, oFormat, sTimezone) {
|
|
2054
|
-
var iTimezoneOffset =
|
|
2064
|
+
var iTimezoneOffset = TimezoneUtils.calculateOffset(oDate, sTimezone);
|
|
2055
2065
|
var iTZOffset = Math.abs(iTimezoneOffset / 60);
|
|
2056
2066
|
var bPositiveOffset = iTimezoneOffset > 0;
|
|
2057
2067
|
var iHourOffset = Math.floor(iTZOffset / 60);
|
|
@@ -2107,7 +2117,7 @@ DateFormat.prototype.oSymbols = {
|
|
|
2107
2117
|
*/
|
|
2108
2118
|
|
|
2109
2119
|
// @see http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Zone_Goals
|
|
2110
|
-
var iTimezoneOffset =
|
|
2120
|
+
var iTimezoneOffset = TimezoneUtils.calculateOffset(oDate, sTimezone);
|
|
2111
2121
|
var iTZOffset = Math.abs(iTimezoneOffset / 60);
|
|
2112
2122
|
var bPositiveOffset = iTimezoneOffset > 0;
|
|
2113
2123
|
var iHourOffset = Math.floor(iTZOffset / 60);
|
|
@@ -2162,7 +2172,7 @@ DateFormat.prototype.oSymbols = {
|
|
|
2162
2172
|
// VV - The long IANA time zone ID
|
|
2163
2173
|
if (oPart.digits === 2) {
|
|
2164
2174
|
var mTimezoneTranslations = oFormat.oLocaleData.getTimezoneTranslations();
|
|
2165
|
-
|
|
2175
|
+
sTimezone = TimezoneUtils.getABAPTimezone(sTimezone);
|
|
2166
2176
|
// shortcut, first try the time zone parameter
|
|
2167
2177
|
if (sValue === mTimezoneTranslations[sTimezone]) {
|
|
2168
2178
|
return {
|
|
@@ -2184,8 +2194,8 @@ DateFormat.prototype.oSymbols = {
|
|
|
2184
2194
|
// find the longest valid time zone ID at the beginning of sValue
|
|
2185
2195
|
for (var i = sValue.length; i > 0; i -= 1) {
|
|
2186
2196
|
sCurrentValue = sValue.slice(0, i);
|
|
2187
|
-
if (
|
|
2188
|
-
oTimezoneParsed.timezone = sCurrentValue;
|
|
2197
|
+
if (TimezoneUtils.isValidTimezone(sCurrentValue)) {
|
|
2198
|
+
oTimezoneParsed.timezone = TimezoneUtils.getABAPTimezone(sCurrentValue);
|
|
2189
2199
|
oTimezoneParsed.length = sCurrentValue.length;
|
|
2190
2200
|
break;
|
|
2191
2201
|
}
|
|
@@ -2232,8 +2242,8 @@ DateFormat.prototype._format = function (oJSDate, bUTC, sTimezone) {
|
|
|
2232
2242
|
/**
|
|
2233
2243
|
* Format a date according to the given format options.
|
|
2234
2244
|
*
|
|
2235
|
-
* Uses the timezone from {@link sap.
|
|
2236
|
-
* browser's local timezone to convert the given date.
|
|
2245
|
+
* Uses the timezone from {@link module:sap/base/i18n/Localization.getTimezone Localization.getTimezone}, which
|
|
2246
|
+
* falls back to the browser's local timezone to convert the given date.
|
|
2237
2247
|
*
|
|
2238
2248
|
* When using instances from getDateTimeWithTimezoneInstance, please see the corresponding documentation:
|
|
2239
2249
|
* {@link sap.ui.core.format.DateFormat.DateTimeWithTimezone#format}.
|
|
@@ -2255,7 +2265,8 @@ DateFormat.prototype.format = function (vJSDate, bUTC) {
|
|
|
2255
2265
|
sTimezone = bUTC;
|
|
2256
2266
|
bUTC = false;
|
|
2257
2267
|
checkTimezoneParameterType(sTimezone);
|
|
2258
|
-
|
|
2268
|
+
sTimezone = TimezoneUtils.getABAPTimezone(sTimezone);
|
|
2269
|
+
if (sTimezone && !TimezoneUtils.isValidTimezone(sTimezone)) {
|
|
2259
2270
|
Log.error("The given timezone isn't valid.");
|
|
2260
2271
|
return "";
|
|
2261
2272
|
}
|
|
@@ -2267,7 +2278,7 @@ DateFormat.prototype.format = function (vJSDate, bUTC) {
|
|
|
2267
2278
|
}
|
|
2268
2279
|
|
|
2269
2280
|
// default the timezone to the local timezone to always enforce the conversion
|
|
2270
|
-
sTimezone = sTimezone ||
|
|
2281
|
+
sTimezone = sTimezone || Localization.getTimezone();
|
|
2271
2282
|
if (Array.isArray(vJSDate)) {
|
|
2272
2283
|
if (!this.oFormatOptions.interval) {
|
|
2273
2284
|
Log.error("Non-interval DateFormat can't format more than one date instance.");
|
|
@@ -2298,9 +2309,8 @@ DateFormat.prototype.format = function (vJSDate, bUTC) {
|
|
|
2298
2309
|
}
|
|
2299
2310
|
} else {
|
|
2300
2311
|
if (!isValidDateObject(vJSDate)) {
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
if (this.type === mDateFormatTypes.DATETIME_WITH_TIMEZONE && this.oFormatOptions.pattern.includes("VV")) {
|
|
2312
|
+
const bNullish = vJSDate === undefined || vJSDate === null;
|
|
2313
|
+
if (bNullish && this.type === mDateFormatTypes.DATETIME_WITH_TIMEZONE && this.oFormatOptions.pattern.includes("VV")) {
|
|
2304
2314
|
return this.oLocaleData.getTimezoneTranslations()[sTimezone] || sTimezone;
|
|
2305
2315
|
}
|
|
2306
2316
|
Log.error("The given date instance isn't valid.");
|
|
@@ -2316,7 +2326,7 @@ DateFormat.prototype.format = function (vJSDate, bUTC) {
|
|
|
2316
2326
|
|
|
2317
2327
|
// Support Japanese Gannen instead of Ichinen for first year of the era
|
|
2318
2328
|
if (sCalendarType === CalendarType.Japanese && this.oLocale.getLanguage() === "ja") {
|
|
2319
|
-
sResult = sResult.replace(/(
|
|
2329
|
+
sResult = sResult.replace(/(^|\D)1\u5e74/g, "$1\u5143\u5e74");
|
|
2320
2330
|
}
|
|
2321
2331
|
return sResult;
|
|
2322
2332
|
};
|
|
@@ -2549,9 +2559,9 @@ DateFormat.prototype._parseInterval = function (sValue, sCalendarType, bUTC, bSt
|
|
|
2549
2559
|
* Retrieves the parameter for the calendar week configuration from the DateFormat's format
|
|
2550
2560
|
* options
|
|
2551
2561
|
*
|
|
2552
|
-
* @param {{firstDayOfWeek: int, minimalDaysInFirstWeek: int, calendarWeekNumbering: sap
|
|
2562
|
+
* @param {{firstDayOfWeek: int, minimalDaysInFirstWeek: int, calendarWeekNumbering: module:sap/base/i18n/date/CalendarWeekNumbering}} oFormatOptions
|
|
2553
2563
|
* The format options with which the DateFormat instance was created
|
|
2554
|
-
* @returns {sap
|
|
2564
|
+
* @returns {module:sap/base/i18n/date/CalendarWeekNumbering|{firstDayOfWeek: int, minimalDaysInFirstWeek: int}|undefined}
|
|
2555
2565
|
* The parameter for the calendar week configuration
|
|
2556
2566
|
*/
|
|
2557
2567
|
function getCalendarWeekParameter(oFormatOptions) {
|
|
@@ -2579,7 +2589,7 @@ var convertToTimezone = function (oJSDate, sTimezone, bUTC) {
|
|
|
2579
2589
|
// Convert to timezone if provided and a valid date is supplied
|
|
2580
2590
|
if (!bUTC && isValidDateObject(oJSDate)) {
|
|
2581
2591
|
// convert given date to a date in the target timezone
|
|
2582
|
-
return
|
|
2592
|
+
return TimezoneUtils.convertToTimezone(oJSDate, sTimezone);
|
|
2583
2593
|
}
|
|
2584
2594
|
return oJSDate;
|
|
2585
2595
|
};
|
|
@@ -2629,7 +2639,7 @@ var fnCreateDate = function (oDateValue, sCalendarType, bUTC, bStrict, sTimezone
|
|
|
2629
2639
|
sTimezone = oDateValue.timezone;
|
|
2630
2640
|
}
|
|
2631
2641
|
if (sTimezone) {
|
|
2632
|
-
oDateValue.tzDiff =
|
|
2642
|
+
oDateValue.tzDiff = TimezoneUtils.calculateOffset(oDate, sTimezone);
|
|
2633
2643
|
}
|
|
2634
2644
|
}
|
|
2635
2645
|
if (oDateValue.tzDiff) {
|
|
@@ -2679,8 +2689,8 @@ function isValidDateObject(oDate) {
|
|
|
2679
2689
|
/**
|
|
2680
2690
|
* Parse a string which is formatted according to the given format options.
|
|
2681
2691
|
*
|
|
2682
|
-
* Uses the timezone from {@link sap.
|
|
2683
|
-
* browser's local timezone to convert the given date.
|
|
2692
|
+
* Uses the timezone from {@link module:sap/base/i18n/Localization.getTimezone Localization.getTimezone}, which
|
|
2693
|
+
* falls back to the browser's local timezone to convert the given date.
|
|
2684
2694
|
*
|
|
2685
2695
|
* When using instances from getDateTimeWithTimezoneInstance, please see the corresponding documentation:
|
|
2686
2696
|
* {@link sap.ui.core.format.DateFormat.DateTimeWithTimezone#parse}.
|
|
@@ -2717,7 +2727,7 @@ DateFormat.prototype.parse = function (sValue, bUTC, bStrict) {
|
|
|
2717
2727
|
sTimezone = bUTC;
|
|
2718
2728
|
bUTC = false;
|
|
2719
2729
|
checkTimezoneParameterType(sTimezone);
|
|
2720
|
-
if (sTimezone && !
|
|
2730
|
+
if (sTimezone && !TimezoneUtils.isValidTimezone(sTimezone)) {
|
|
2721
2731
|
Log.error("The given timezone isn't valid.");
|
|
2722
2732
|
return null;
|
|
2723
2733
|
}
|
|
@@ -2725,19 +2735,19 @@ DateFormat.prototype.parse = function (sValue, bUTC, bStrict) {
|
|
|
2725
2735
|
sValue = sValue == null ? "" : String(sValue).trim();
|
|
2726
2736
|
// normalize input by removing all RTL special characters and replacing all special spaces
|
|
2727
2737
|
// by a standard space (\u0020)
|
|
2728
|
-
sValue =
|
|
2738
|
+
sValue = FormatUtils.normalize(sValue);
|
|
2729
2739
|
var oDateValue;
|
|
2730
2740
|
var sCalendarType = this.oFormatOptions.calendarType;
|
|
2731
2741
|
|
|
2732
2742
|
// default the timezone to the local timezone to always enforce the conversion
|
|
2733
|
-
sTimezone = sTimezone ||
|
|
2743
|
+
sTimezone = sTimezone || Localization.getTimezone();
|
|
2734
2744
|
if (bStrict === undefined) {
|
|
2735
2745
|
bStrict = this.oFormatOptions.strictParsing;
|
|
2736
2746
|
}
|
|
2737
2747
|
|
|
2738
2748
|
// Support Japanese Gannen instead of Ichinen for first year of the era
|
|
2739
2749
|
if (sCalendarType === CalendarType.Japanese && this.oLocale.getLanguage() === "ja") {
|
|
2740
|
-
sValue = sValue.replace(
|
|
2750
|
+
sValue = sValue.replace(/\u5143\u5e74/g, "1\u5e74");
|
|
2741
2751
|
}
|
|
2742
2752
|
if (!this.oFormatOptions.interval) {
|
|
2743
2753
|
var oJSDate = this.parseRelative(sValue, bUTC);
|
|
@@ -3266,7 +3276,7 @@ DateFormat.prototype.getAllowedCharacters = function (aFormatArray) {
|
|
|
3266
3276
|
* @ui5-restricted sap.m
|
|
3267
3277
|
*/
|
|
3268
3278
|
DateFormat.prototype.getPlaceholderText = function () {
|
|
3269
|
-
var oResourceBundle =
|
|
3279
|
+
var oResourceBundle = Library.getResourceBundleFor("sap.ui.core");
|
|
3270
3280
|
return oResourceBundle.getText("date.placeholder", [this.format.apply(this, this.getSampleValue())]);
|
|
3271
3281
|
};
|
|
3272
3282
|
|
|
@@ -3287,24 +3297,11 @@ DateFormat.prototype.getSampleValue = function () {
|
|
|
3287
3297
|
}
|
|
3288
3298
|
oDate = getDate(iFullYear, 11, 31, 23, 59, 58, 123);
|
|
3289
3299
|
if (this.type === mDateFormatTypes.DATETIME_WITH_TIMEZONE) {
|
|
3290
|
-
return [oDate,
|
|
3300
|
+
return [oDate, Localization.getTimezone()];
|
|
3291
3301
|
}
|
|
3292
3302
|
if (this.oFormatOptions.interval) {
|
|
3293
3303
|
return [[getDate(iFullYear, 11, 22, 9, 12, 34, 567), oDate]];
|
|
3294
3304
|
}
|
|
3295
3305
|
return [oDate];
|
|
3296
3306
|
};
|
|
3297
|
-
const rAllRTLCharacters = /[\u200e\u200f\u202a\u202b\u202c]/g;
|
|
3298
|
-
const rAllSpaces = /\s/g;
|
|
3299
|
-
|
|
3300
|
-
/**
|
|
3301
|
-
* Normalizes the given string by removing RTL characters and replacing special space characters
|
|
3302
|
-
* by the standard ASCII space (\u0020).
|
|
3303
|
-
*
|
|
3304
|
-
* @param {string} sValue The value to be normalized
|
|
3305
|
-
* @return {string} The normalized value
|
|
3306
|
-
*/
|
|
3307
|
-
DateFormat._normalize = function (sValue) {
|
|
3308
|
-
return sValue.replace(rAllRTLCharacters, "").replace(rAllSpaces, " ");
|
|
3309
|
-
};
|
|
3310
3307
|
export default DateFormat;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatter related utility functions
|
|
3
|
+
*
|
|
4
|
+
* @author SAP SE
|
|
5
|
+
* @version 1.146.0
|
|
6
|
+
* @namespace
|
|
7
|
+
* @private
|
|
8
|
+
*/ /*!
|
|
9
|
+
* OpenUI5
|
|
10
|
+
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const FormatUtils = {};
|
|
15
|
+
// https://www.unicode.org/reports/tr44/#Bidi_Class_Values (Explicit Formatting Types)
|
|
16
|
+
const rAllRTLCharacters = /[\u061c\u200e\u200f\u202a\u202b\u202c]/g;
|
|
17
|
+
const rAllSpaces = /\s/g;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Normalizes the given string by removing RTL characters and either by replacing special space
|
|
21
|
+
* characters by the standard ASCII space (\u0020) or removing all spaces.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} sValue The value to be normalized
|
|
24
|
+
* @param {boolean} [bRemoveSpaces=false] Whether all spaces are removed
|
|
25
|
+
* @returns {string} The normalized value
|
|
26
|
+
*/
|
|
27
|
+
FormatUtils.normalize = function (sValue, bRemoveSpaces) {
|
|
28
|
+
return sValue.replace(rAllRTLCharacters, "").replace(rAllSpaces, bRemoveSpaces ? "" : " ");
|
|
29
|
+
};
|
|
30
|
+
export default FormatUtils;
|