@ui5/webcomponents-localization 2.26.0-rc.0 → 2.26.0
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/ar.json +21 -0
- package/dist/generated/assets/cldr/ar_EG.json +21 -0
- package/dist/generated/assets/cldr/ar_SA.json +21 -0
- package/dist/generated/assets/cldr/bg.json +21 -0
- package/dist/generated/assets/cldr/ca.json +21 -0
- package/dist/generated/assets/cldr/cnr.json +21 -0
- package/dist/generated/assets/cldr/cs.json +21 -0
- package/dist/generated/assets/cldr/cy.json +21 -0
- package/dist/generated/assets/cldr/da.json +21 -0
- package/dist/generated/assets/cldr/de.json +21 -0
- package/dist/generated/assets/cldr/de_AT.json +21 -0
- package/dist/generated/assets/cldr/de_CH.json +21 -0
- package/dist/generated/assets/cldr/el.json +21 -0
- package/dist/generated/assets/cldr/el_CY.json +21 -0
- package/dist/generated/assets/cldr/en.json +21 -0
- package/dist/generated/assets/cldr/en_AU.json +21 -0
- package/dist/generated/assets/cldr/en_GB.json +21 -0
- package/dist/generated/assets/cldr/en_HK.json +21 -0
- package/dist/generated/assets/cldr/en_IE.json +21 -0
- package/dist/generated/assets/cldr/en_IN.json +21 -0
- package/dist/generated/assets/cldr/en_NZ.json +21 -0
- package/dist/generated/assets/cldr/en_PG.json +21 -0
- package/dist/generated/assets/cldr/en_SG.json +21 -0
- package/dist/generated/assets/cldr/en_ZA.json +21 -0
- package/dist/generated/assets/cldr/es.json +21 -0
- package/dist/generated/assets/cldr/es_AR.json +21 -0
- package/dist/generated/assets/cldr/es_BO.json +21 -0
- package/dist/generated/assets/cldr/es_CL.json +21 -0
- package/dist/generated/assets/cldr/es_CO.json +21 -0
- package/dist/generated/assets/cldr/es_MX.json +21 -0
- package/dist/generated/assets/cldr/es_PE.json +21 -0
- package/dist/generated/assets/cldr/es_UY.json +21 -0
- package/dist/generated/assets/cldr/es_VE.json +21 -0
- package/dist/generated/assets/cldr/et.json +21 -0
- package/dist/generated/assets/cldr/fa.json +21 -0
- package/dist/generated/assets/cldr/fi.json +21 -0
- package/dist/generated/assets/cldr/fr.json +21 -0
- package/dist/generated/assets/cldr/fr_BE.json +21 -0
- package/dist/generated/assets/cldr/fr_CA.json +21 -0
- package/dist/generated/assets/cldr/fr_CH.json +21 -0
- package/dist/generated/assets/cldr/fr_LU.json +21 -0
- package/dist/generated/assets/cldr/he.json +21 -0
- package/dist/generated/assets/cldr/hi.json +21 -0
- package/dist/generated/assets/cldr/hr.json +21 -0
- package/dist/generated/assets/cldr/hu.json +21 -0
- package/dist/generated/assets/cldr/id.json +21 -0
- package/dist/generated/assets/cldr/it.json +21 -0
- package/dist/generated/assets/cldr/it_CH.json +21 -0
- package/dist/generated/assets/cldr/ja.json +21 -0
- package/dist/generated/assets/cldr/kk.json +21 -0
- package/dist/generated/assets/cldr/ko.json +21 -0
- package/dist/generated/assets/cldr/lt.json +21 -0
- package/dist/generated/assets/cldr/lv.json +21 -0
- package/dist/generated/assets/cldr/mk.json +21 -0
- package/dist/generated/assets/cldr/ms.json +21 -0
- package/dist/generated/assets/cldr/nb.json +21 -0
- package/dist/generated/assets/cldr/nl.json +21 -0
- package/dist/generated/assets/cldr/nl_BE.json +21 -0
- package/dist/generated/assets/cldr/pl.json +21 -0
- package/dist/generated/assets/cldr/pt.json +21 -0
- package/dist/generated/assets/cldr/pt_PT.json +21 -0
- package/dist/generated/assets/cldr/ro.json +21 -0
- package/dist/generated/assets/cldr/ru.json +21 -0
- package/dist/generated/assets/cldr/ru_UA.json +21 -0
- package/dist/generated/assets/cldr/sk.json +21 -0
- package/dist/generated/assets/cldr/sl.json +21 -0
- package/dist/generated/assets/cldr/sr.json +21 -0
- package/dist/generated/assets/cldr/sr_Latn.json +21 -0
- package/dist/generated/assets/cldr/sv.json +21 -0
- package/dist/generated/assets/cldr/th.json +21 -0
- package/dist/generated/assets/cldr/tr.json +21 -0
- package/dist/generated/assets/cldr/uk.json +21 -0
- package/dist/generated/assets/cldr/vi.json +21 -0
- package/dist/generated/assets/cldr/zh_CN.json +21 -0
- package/dist/generated/assets/cldr/zh_HK.json +21 -0
- package/dist/generated/assets/cldr/zh_SG.json +21 -0
- package/dist/generated/assets/cldr/zh_TW.json +21 -0
- package/dist/sap/base/Event.js +1 -1
- package/dist/sap/base/Eventing.js +1 -1
- package/dist/sap/base/i18n/LanguageTag.js +1 -1
- package/dist/sap/base/i18n/date/TimezoneUtils.js +1 -1
- package/dist/sap/base/util/Version.js +1 -1
- package/dist/sap/base/util/deepEqual.js +2 -2
- package/dist/sap/ui/base/Metadata.js +1 -1
- package/dist/sap/ui/base/Object.js +1 -1
- package/dist/sap/ui/core/Locale.js +1 -1
- package/dist/sap/ui/core/LocaleData.js +23 -1
- package/dist/sap/ui/core/date/UI5Date.js +1 -1
- package/dist/sap/ui/core/format/DateFormat.js +101 -14
- package/dist/sap/ui/core/format/FormatUtils.js +1 -1
- package/dist/sap/ui/core/format/NumberFormat.js +403 -344
- package/dist/sap/ui/core/format/TimezoneUtil.js +1 -1
- package/package.json +9 -9
|
@@ -14,6 +14,335 @@ import FormatUtils from "./FormatUtils.js";
|
|
|
14
14
|
import Log from "../../../base/Log.js";
|
|
15
15
|
import assert from "../../../base/assert.js";
|
|
16
16
|
import extend from "../../../base/util/extend.js";
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} sap.ui.core.format.NumberFormat.FormatOptions
|
|
19
|
+
*
|
|
20
|
+
* The base type for the numeric format options.
|
|
21
|
+
*
|
|
22
|
+
* @property {string} [decimalSeparator]
|
|
23
|
+
* The character used as decimal separator.
|
|
24
|
+
* If none is given, the locale-specific decimal separator is used.
|
|
25
|
+
* <b>Note:</b> <code>decimalSeparator</code> must always be different from <code>groupingSeparator</code>.
|
|
26
|
+
* @property {int} [groupingBaseSize]
|
|
27
|
+
* The grouping base size in digits if it is different from the grouping size (e.g. Indian grouping).
|
|
28
|
+
* @property {boolean} [groupingEnabled]
|
|
29
|
+
* Whether grouping is enabled (grouping separators are shown).
|
|
30
|
+
* <b>Note:</b> Grouping is disabled if the <code>groupingSize</code> format option is set to
|
|
31
|
+
* a non-positive value.
|
|
32
|
+
* @property {string} [groupingSeparator]
|
|
33
|
+
* The character used as grouping separator.
|
|
34
|
+
* If none is given, the locale-specific grouping separator is used.
|
|
35
|
+
* <b>Note:</b> <code>groupingSeparator</code> must always be different from <code>decimalSeparator</code>.
|
|
36
|
+
* @property {int} [groupingSize]
|
|
37
|
+
* The grouping size in digits.
|
|
38
|
+
* <b>Note:</b> Grouping is disabled if this format option is set to a non-positive value.
|
|
39
|
+
* @property {int} [maxFractionDigits]
|
|
40
|
+
* The maximum number of decimal digits.
|
|
41
|
+
* @property {int} [maxIntegerDigits]
|
|
42
|
+
* The maximum number of non-decimal digits.
|
|
43
|
+
* @property {int} [minIntegerDigits]
|
|
44
|
+
* The minimal number of non-decimal digits.
|
|
45
|
+
* @property {string} [minusSign]
|
|
46
|
+
* The symbol for the minus sign.
|
|
47
|
+
* If none is given, the locale-specific minus sign is used.
|
|
48
|
+
* @property {string} [pattern]
|
|
49
|
+
* The CLDR number pattern which is used to format a number.
|
|
50
|
+
* If none is given, the default pattern for the locale and type is used.
|
|
51
|
+
* @property {string} [plusSign]
|
|
52
|
+
* The symbol for the plus sign.
|
|
53
|
+
* If none is given, the locale-specific plus sign is used.
|
|
54
|
+
* @property {sap.ui.core.format.NumberFormat.RoundingMode|function} [roundingMode]
|
|
55
|
+
* Defines how numbers are rounded when the number of fraction digits exceeds the value of
|
|
56
|
+
* <code>maxFractionDigits</code>.
|
|
57
|
+
* The rounding behavior of the formatter can be defined in the following ways:
|
|
58
|
+
* <ul>
|
|
59
|
+
* <li>Setting this format option to a value from the
|
|
60
|
+
* {@link sap.ui.core.format.NumberFormat.RoundingMode RoundingMode} enum</li>
|
|
61
|
+
* <li>Setting this format option to a function used for rounding the number.
|
|
62
|
+
* The function must take two parameters: the number itself, and the number of decimal digits
|
|
63
|
+
* that should be preserved. String-based numbers are not rounded by this custom function.
|
|
64
|
+
* <b>Deprecated as of version 1.121.0; apply rounding by specifying a rounding mode instead.</b>
|
|
65
|
+
* </li>
|
|
66
|
+
* </ul>
|
|
67
|
+
* @property {int} [shortDecimals]
|
|
68
|
+
* The number of decimals in the shortened format string.
|
|
69
|
+
* If this option isn't specified, the <code>decimals</code> option is used instead.
|
|
70
|
+
* @property {int} [shortLimit]
|
|
71
|
+
* A limit above which only short number formatting is used.
|
|
72
|
+
* @property {int} [shortRefNumber]
|
|
73
|
+
* Since 1.40, specifies a number from which the scale factor for the <code>short</code> or <code>long</code>
|
|
74
|
+
* style format is generated.
|
|
75
|
+
* The generated scale factor is used for all numbers which are formatted with this format instance.
|
|
76
|
+
* This option only takes effect when the <code>style</code> option is set to <code>short</code> or
|
|
77
|
+
* <code>long</code>.
|
|
78
|
+
* It is set to <code>undefined</code> by default, which means that the scale factor is selected
|
|
79
|
+
* automatically for each number being formatted.
|
|
80
|
+
* @property {boolean} [showScale]
|
|
81
|
+
* Since 1.40, specifies whether the scale factor is shown in the formatted number.
|
|
82
|
+
* This option takes effect only when the <code>style</code> option is set to either
|
|
83
|
+
* <code>short</code> or <code>long</code>.
|
|
84
|
+
* @property {boolean} [strictGroupingValidation]
|
|
85
|
+
* Whether the positions of grouping separators are validated. Space characters used as grouping
|
|
86
|
+
* separators are not validated.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @typedef {sap.ui.core.format.NumberFormat.FormatOptions} sap.ui.core.format.NumberFormat.IntegerFormatOptions
|
|
93
|
+
*
|
|
94
|
+
* The format options for integer numbers.
|
|
95
|
+
*
|
|
96
|
+
* @property {int} [decimals]
|
|
97
|
+
* The number of decimal digits.
|
|
98
|
+
* @property {null|number|string} [emptyString]
|
|
99
|
+
* Since 1.130.0. Defines what value an empty string is parsed into and what value is formatted as an empty
|
|
100
|
+
* string.
|
|
101
|
+
* The {@link #format} and {@link #parse} functions are done in a symmetric way.
|
|
102
|
+
* For example, when this parameter is set to <code>NaN</code>, an empty string is parsed as <code>NaN</code>,
|
|
103
|
+
* and <code>NaN</code> is formatted as an empty string.
|
|
104
|
+
* @property {int} [minFractionDigits]
|
|
105
|
+
* The minimal number of decimal digits.
|
|
106
|
+
* @property {int} [precision]
|
|
107
|
+
* <b>Note:</b> Only considered if the number format leads to a
|
|
108
|
+
* representation with decimal places, e.g. if the option <code>style: "short"</code> is set.
|
|
109
|
+
* The maximum number of digits in the formatted representation of a number; if the <code>precision</code> is
|
|
110
|
+
* less than the overall length of the number, its fractional part is truncated through rounding.
|
|
111
|
+
* As the <code>precision</code> only affects the rounding of a number, its integer part can retain more digits
|
|
112
|
+
* than defined by this parameter.
|
|
113
|
+
* <b>Example:</b> With a <code>precision</code> of 2 and <code>style: "short"</code>,
|
|
114
|
+
* <code>234567</code> is formatted to <code>"235K"</code>.
|
|
115
|
+
* @property {boolean} [parseAsString]
|
|
116
|
+
* Since 1.28.2, whether to parse the number as a string in order to keep the precision for big numbers. Numbers
|
|
117
|
+
* in scientific notation are parsed back to standard notation.
|
|
118
|
+
* For example, <code>5e-3</code> is parsed to <code>0.005</code>.
|
|
119
|
+
* @property {boolean} [preserveDecimals]
|
|
120
|
+
* Whether {@link #format} preserves decimal digits (except trailing zeros) when there are more decimals than the
|
|
121
|
+
* <code>maxFractionDigits</code> format option allows.
|
|
122
|
+
* When decimals aren't preserved, the formatted number is rounded to <code>maxFractionDigits</code>.
|
|
123
|
+
* @property {"short"|"long"|"standard"} [style]
|
|
124
|
+
* The style of format.
|
|
125
|
+
* When set to <code>short</code> or <code>long</code>, numbers are formatted into compact forms.
|
|
126
|
+
* When this option is set, the default value of the <code>precision</code> option is set to <code>2</code>.
|
|
127
|
+
* This can be changed by setting either <code>min/maxFractionDigits</code>,
|
|
128
|
+
* <code>decimals</code>, <code>shortDecimals</code>, or the <code>precision</code> option itself.
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @typedef {sap.ui.core.format.NumberFormat.FormatOptions} sap.ui.core.format.NumberFormat.FloatFormatOptions
|
|
135
|
+
*
|
|
136
|
+
* The format options for floating-point numbers.
|
|
137
|
+
*
|
|
138
|
+
* @property {int} [decimals]
|
|
139
|
+
* The number of decimal digits.
|
|
140
|
+
* @property {int} [decimalPadding]
|
|
141
|
+
* The target length of places after the decimal separator; if the number has fewer decimal places than given in
|
|
142
|
+
* this option, it is padded with whitespaces at the end up to the target length. An additional whitespace
|
|
143
|
+
* character for the decimal separator is added for a number without any decimals.
|
|
144
|
+
* <b>Note:</b> This format option is only allowed if the following conditions apply:
|
|
145
|
+
* <ul>
|
|
146
|
+
* <li>It has a value greater than 0.</li>
|
|
147
|
+
* <li>The <code>oFormatOptions.style</code> format option is <b>not</b> set to <code>"short"</code> or
|
|
148
|
+
* <code>"long"</code>.</li>
|
|
149
|
+
* </ul>
|
|
150
|
+
* @property {null|number|string} [emptyString]
|
|
151
|
+
* Since 1.130.0. Defines what value an empty string is parsed into and what value is formatted as an empty
|
|
152
|
+
* string.
|
|
153
|
+
* The {@link #format} and {@link #parse} functions are done in a symmetric way.
|
|
154
|
+
* For example, when this parameter is set to <code>NaN</code>, an empty string is parsed as <code>NaN</code>,
|
|
155
|
+
* and <code>NaN</code> is formatted as an empty string.
|
|
156
|
+
* @property {int} [minFractionDigits]
|
|
157
|
+
* The minimal number of decimal digits.
|
|
158
|
+
* @property {boolean} [parseAsString]
|
|
159
|
+
* Since 1.28.2, whether to parse the number as a string in order to keep the precision for big numbers. Numbers
|
|
160
|
+
* in scientific notation are parsed back to standard notation.
|
|
161
|
+
* For example, <code>5e-3</code> is parsed to <code>0.005</code>.
|
|
162
|
+
* @property {int} [precision]
|
|
163
|
+
* The maximum number of digits in the formatted representation of a number;
|
|
164
|
+
* if the <code>precision</code> is less than the overall length of the number, its fractional part is truncated
|
|
165
|
+
* through rounding. As the <code>precision</code> only affects the rounding of a number, its integer part can
|
|
166
|
+
* retain more digits than defined by this parameter.
|
|
167
|
+
* <b>Example:</b> With a <code>precision</code> of 2, <code>234.567</code> is formatted to <code>235</code>.
|
|
168
|
+
* <b>Note:</b> The formatted output may differ depending on locale.
|
|
169
|
+
* @property {boolean} [preserveDecimals]
|
|
170
|
+
* Whether {@link #format} preserves decimal digits (except trailing zeros) when there are more decimals than the
|
|
171
|
+
* <code>maxFractionDigits</code> format option allows.
|
|
172
|
+
* When decimals aren't preserved, the formatted number is rounded to <code>maxFractionDigits</code>.
|
|
173
|
+
* @property {"short"|"long"|"standard"} [style]
|
|
174
|
+
* The style of format.
|
|
175
|
+
* When set to <code>short</code> or <code>long</code>, numbers are formatted into compact forms.
|
|
176
|
+
* When this option is set, the default value of the <code>precision</code> option is set to <code>2</code>.
|
|
177
|
+
* This can be changed by setting either <code>min/maxFractionDigits</code>,
|
|
178
|
+
* <code>decimals</code>, <code>shortDecimals</code>, or the <code>precision</code> option itself.
|
|
179
|
+
*
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @typedef {sap.ui.core.format.NumberFormat.FormatOptions} sap.ui.core.format.NumberFormat.UnitFormatOptions
|
|
185
|
+
*
|
|
186
|
+
* The format options for units.
|
|
187
|
+
*
|
|
188
|
+
* @property {Array<string>} [allowedUnits]
|
|
189
|
+
* Defines the allowed units for formatting and parsing, for example <code>["size-meter", "volume-liter", ...]</code>
|
|
190
|
+
* If this option is not specified, all units are allowed.
|
|
191
|
+
* @property {Object<string,object>} [customUnits]
|
|
192
|
+
* Defines a set of custom units, for example:
|
|
193
|
+
* <pre><code>{"electric-inductance": {
|
|
194
|
+
* "displayName": "henry",
|
|
195
|
+
* "unitPattern-count-one": "{0} H",
|
|
196
|
+
* "unitPattern-count-other": "{0} H",
|
|
197
|
+
* "perUnitPattern": "{0}/H",
|
|
198
|
+
* "decimals": 2,
|
|
199
|
+
* "precision": 4
|
|
200
|
+
* }
|
|
201
|
+
* }</code></pre>
|
|
202
|
+
* @property {int} [decimals]
|
|
203
|
+
* The number of decimal digits.
|
|
204
|
+
* @property {int} [decimalPadding]
|
|
205
|
+
* The target length of places after the decimal separator; if the number has fewer decimals than specified in
|
|
206
|
+
* this option, it is padded with whitespaces at the end up to the target length. An additional whitespace
|
|
207
|
+
* character for the decimal separator is added for a number without any decimals.
|
|
208
|
+
* <b>Note:</b> This format option is only allowed if the following conditions apply:
|
|
209
|
+
* <ul>
|
|
210
|
+
* <li>It has a value greater than 0.</li>
|
|
211
|
+
* <li>The <code>oFormatOptions.style</code> format option is <b>not</b> set to <code>"short"</code> or
|
|
212
|
+
* <code>"long"</code>.</li>
|
|
213
|
+
* </ul>
|
|
214
|
+
* @property {null|number|string} [emptyString]
|
|
215
|
+
* Since 1.130.0. Defines what value an empty string is parsed into and what value is formatted as an empty
|
|
216
|
+
* string.
|
|
217
|
+
* The {@link #format} and {@link #parse} functions are done in a symmetric way.
|
|
218
|
+
* For example, when this parameter is set to <code>NaN</code>, an empty string is parsed as <code>NaN</code>,
|
|
219
|
+
* and <code>NaN</code> is formatted as an empty string.
|
|
220
|
+
* @property {int} [minFractionDigits]
|
|
221
|
+
* The minimal number of decimal digits.
|
|
222
|
+
* @property {boolean} [parseAsString]
|
|
223
|
+
* Since 1.28.2, whether to parse the number as a string in order to keep the precision for big numbers. Numbers
|
|
224
|
+
* in scientific notation are parsed back to standard notation.
|
|
225
|
+
* For example, <code>5e-3</code> is parsed to <code>0.005</code>.
|
|
226
|
+
* @property {int} [precision]
|
|
227
|
+
* The maximum number of digits in the formatted representation of a number;
|
|
228
|
+
* if the <code>precision</code> is less than the overall length of the number, its fractional part is truncated
|
|
229
|
+
* through rounding. As the <code>precision</code> only affects the rounding of a number, its integer part can
|
|
230
|
+
* retain more digits than defined by this parameter.
|
|
231
|
+
* <b>Example:</b> With a <code>precision</code> of 2, <code>234.567</code> is formatted to <code>235</code>.
|
|
232
|
+
* <b>Note:</b> The formatted output may differ depending on locale.
|
|
233
|
+
* @property {boolean} [preserveDecimals]
|
|
234
|
+
* Whether {@link #format} preserves decimal digits (except trailing zeros) when there are more decimals than the
|
|
235
|
+
* <code>maxFractionDigits</code> format option allows.
|
|
236
|
+
* When decimals aren't preserved, the formatted number is rounded to <code>maxFractionDigits</code>.
|
|
237
|
+
* @property {boolean} [showMeasure]
|
|
238
|
+
* Defines whether the unit of measure is shown in the formatted string, for example 1 day for locale "en"
|
|
239
|
+
* <pre><code>NumberFormat.getUnitInstance({showMeasure: true})
|
|
240
|
+
* .format(1, "duration-day"); // "1 day"</code></pre>
|
|
241
|
+
* <pre><code>NumberFormat.getUnitInstance({showMeasure: false})
|
|
242
|
+
* .format(1, "duration-day"); // "1"</code></pre>
|
|
243
|
+
* If both <code>showMeasure</code> and <code>showNumber</code> are set to false, an empty string is returned.
|
|
244
|
+
* @property {boolean} [showNumber]
|
|
245
|
+
* Defines whether the number is shown as part of the formatted string, for example 1 day for locale "en"
|
|
246
|
+
* <pre><code>NumberFormat.getUnitInstance({showNumber: true})
|
|
247
|
+
* .format(1, "duration-day"); // "1 day"</code></pre>
|
|
248
|
+
* <pre><code>NumberFormat.getUnitInstance({showNumber: false})
|
|
249
|
+
* .format(1, "duration-day"); // "day"</code></pre>
|
|
250
|
+
* If both <code>showMeasure</code> and <code>showNumber</code> are false, an empty string is returned
|
|
251
|
+
* @property {"short"|"long"|"standard"} [style]
|
|
252
|
+
* The style of format.
|
|
253
|
+
* When set to <code>short</code> or <code>long</code>, numbers are formatted into compact forms.
|
|
254
|
+
* When this option is set, the default value of the <code>precision</code> option is set to <code>2</code>.
|
|
255
|
+
* This can be changed by setting either <code>min/maxFractionDigits</code>,
|
|
256
|
+
* <code>decimals</code>, <code>shortDecimals</code>, or the <code>precision</code> option itself.
|
|
257
|
+
*
|
|
258
|
+
* @public
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @typedef {sap.ui.core.format.NumberFormat.FormatOptions} sap.ui.core.format.NumberFormat.CurrencyFormatOptions
|
|
263
|
+
*
|
|
264
|
+
* The format options for currencies.
|
|
265
|
+
*
|
|
266
|
+
* @property {boolean} [currencyCode]
|
|
267
|
+
* Defines whether the currency is shown as a code in currency format.
|
|
268
|
+
* The currency symbol is displayed when this option is set to
|
|
269
|
+
* <code>false</code> and a symbol has been defined for the given currency code.
|
|
270
|
+
* @property {"standard"|"accounting"|"sap-standard"|"sap-accounting"} [currencyContext]
|
|
271
|
+
* Can be set either to 'standard'
|
|
272
|
+
* (the default value) or to 'accounting' for an accounting-specific currency display
|
|
273
|
+
* @property {Object<string,object>} [customCurrencies]
|
|
274
|
+
* Defines a set of custom currencies exclusive to this NumberFormat instance.
|
|
275
|
+
* Custom currencies must not only consist of digits.
|
|
276
|
+
* If custom currencies are defined on the instance, no other currencies can be formatted and
|
|
277
|
+
* parsed by this instance.
|
|
278
|
+
* Globally available custom currencies can be added via the global configuration.
|
|
279
|
+
* See the above examples.
|
|
280
|
+
* See also {@link module:sap/base/i18n/Formatting.setCustomCurrencies Formatting.setCustomCurrencies} and
|
|
281
|
+
* {@link module:sap/base/i18n/Formatting.addCustomCurrencies Formatting.addCustomCurrencies}.
|
|
282
|
+
* @property {int} [decimals]
|
|
283
|
+
* The number of decimal digits.
|
|
284
|
+
* @property {int} [decimalPadding]
|
|
285
|
+
* The target length of places after the decimal separator; if the number has fewer decimals than specified in
|
|
286
|
+
* this option, it is padded with whitespaces at the end up to the target length. An additional whitespace
|
|
287
|
+
* character for the decimal separator is added for a number without any decimals.
|
|
288
|
+
* <b>Note:</b> This format option is only allowed if the following conditions apply:
|
|
289
|
+
* <ul>
|
|
290
|
+
* <li>It has a value greater than 0.</li>
|
|
291
|
+
* <li>The <code>oFormatOptions.style</code> format option is <b>not</b> set to <code>"short"</code> or
|
|
292
|
+
* <code>"long"</code>.</li>
|
|
293
|
+
* </ul>
|
|
294
|
+
* @property {null|number|string} [emptyString]
|
|
295
|
+
* Since 1.130.0. Defines what value an empty string is parsed into and what value is formatted as an empty
|
|
296
|
+
* string.
|
|
297
|
+
* The {@link #format} and {@link #parse} functions are done in a symmetric way.
|
|
298
|
+
* For example, when this parameter is set to <code>NaN</code>, an empty string is parsed as <code>NaN</code>,
|
|
299
|
+
* and <code>NaN</code> is formatted as an empty string.
|
|
300
|
+
* @property {int} [minFractionDigits]
|
|
301
|
+
* Deprecated as of 1.130; this format option does not have
|
|
302
|
+
* an effect on currency formats since decimals can always be determined, either through the given format options,
|
|
303
|
+
* custom currencies or the CLDR
|
|
304
|
+
* @property {boolean} [parseAsString]
|
|
305
|
+
* Since 1.28.2, whether to parse the number as a string in order to keep the precision for big numbers. Numbers
|
|
306
|
+
* in scientific notation are parsed back to standard notation.
|
|
307
|
+
* For example, <code>5e-3</code> is parsed to <code>0.005</code>.
|
|
308
|
+
* @property {int} [precision]
|
|
309
|
+
* The maximum number of digits in the formatted representation of a number;
|
|
310
|
+
* if the <code>precision</code> is less than the overall length of the number, its fractional part is truncated
|
|
311
|
+
* through rounding. As the <code>precision</code> only affects the rounding of a number, its integer part can
|
|
312
|
+
* retain more digits than defined by this parameter.
|
|
313
|
+
* <b>Example:</b> With a <code>precision</code> of 2, <code>234.567</code> is formatted to <code>235</code>.
|
|
314
|
+
* <b>Note:</b> The formatted output may differ depending on locale.
|
|
315
|
+
* @property {boolean} [preserveDecimals]
|
|
316
|
+
* Whether {@link #format} preserves decimal digits (except trailing zeros) when there are more decimals than the
|
|
317
|
+
* <code>maxFractionDigits</code> format option allows.
|
|
318
|
+
* When decimals aren't preserved, the formatted number is rounded to <code>maxFractionDigits</code>.
|
|
319
|
+
* @property {boolean} [showMeasure]
|
|
320
|
+
* Defines whether the currency code/symbol is shown in the formatted string,
|
|
321
|
+
* e.g. true: "1.00 EUR", false: "1.00" for locale "en"
|
|
322
|
+
* If both <code>showMeasure</code> and <code>showNumber</code> are false, an empty string is returned
|
|
323
|
+
* @property {boolean} [showNumber]
|
|
324
|
+
* Defines whether the number is shown as part of the result string,
|
|
325
|
+
* e.g. 1 EUR for locale "en"
|
|
326
|
+
* <pre><code>NumberFormat.getCurrencyInstance({showNumber: true}).format(1, "EUR"); // "1.00 EUR"</code></pre>
|
|
327
|
+
* <pre><code>NumberFormat.getCurrencyInstance({showNumber: false}).format(1, "EUR"); // "EUR"</code></pre>
|
|
328
|
+
* If both <code>showMeasure</code> and <code>showNumber</code> are false, an empty string is returned
|
|
329
|
+
* @property {"short"|"long"|"standard"} [style]
|
|
330
|
+
* The style of format.
|
|
331
|
+
* When set to <code>short</code> or <code>long</code>, numbers are formatted into the <code>short</code> form
|
|
332
|
+
* only.
|
|
333
|
+
* When this option is set, the default value of the <code>precision</code> option is set to <code>2</code>.
|
|
334
|
+
* This can be changed by setting either <code>min/maxFractionDigits</code>,
|
|
335
|
+
* <code>decimals</code>, <code>shortDecimals</code>, or the <code>precision</code> option itself.
|
|
336
|
+
* @property {boolean} [trailingCurrencyCode]
|
|
337
|
+
* Overrides the global configuration
|
|
338
|
+
* value {@link module:sap/base/i18n/Formatting.getTrailingCurrencyCode Formatting.getTrailingCurrencyCode},
|
|
339
|
+
* which has a default value of <code>true</code>.
|
|
340
|
+
* This is ignored if <code>oFormatOptions.currencyCode</code> is set to <code>false</code>,
|
|
341
|
+
* or if <code>oFormatOptions.pattern</code> is supplied.
|
|
342
|
+
*
|
|
343
|
+
* @public
|
|
344
|
+
*/
|
|
345
|
+
|
|
17
346
|
/**
|
|
18
347
|
* Format classes
|
|
19
348
|
*
|
|
@@ -551,82 +880,24 @@ NumberFormat.getInstance = function (oFormatOptions, oLocale) {
|
|
|
551
880
|
* oFormat.format(1234.56); // "1.234,56"
|
|
552
881
|
* </pre>
|
|
553
882
|
*
|
|
554
|
-
* @param {
|
|
883
|
+
* @param {sap.ui.core.format.NumberFormat.FloatFormatOptions} [oFormatOptions={
|
|
884
|
+
* emptyString: NaN,
|
|
885
|
+
* groupingBaseSize: 3,
|
|
886
|
+
* groupingEnabled: true,
|
|
887
|
+
* groupingSize: 3,
|
|
888
|
+
* maxFractionDigits: 99,
|
|
889
|
+
* maxIntegerDigits: 99,
|
|
890
|
+
* minFractionDigits: 0,
|
|
891
|
+
* minIntegerDigits: 1,
|
|
892
|
+
* parseAsString: false,
|
|
893
|
+
* preserveDecimals: false,
|
|
894
|
+
* roundingMode: "HALF_AWAY_FROM_ZERO",
|
|
895
|
+
* showScale: true,
|
|
896
|
+
* strictGroupingValidation: false,
|
|
897
|
+
* style: "standard"
|
|
898
|
+
* }]
|
|
899
|
+
* The option object, which supports the following parameters.
|
|
555
900
|
* If no options are given, default values according to the type and locale settings are used.
|
|
556
|
-
* @param {int} [oFormatOptions.decimalPadding]
|
|
557
|
-
* The target length of places after the decimal separator; if the number has fewer decimal places than given in
|
|
558
|
-
* this option, it is padded with whitespaces at the end up to the target length. An additional whitespace
|
|
559
|
-
* character for the decimal separator is added for a number without any decimals.
|
|
560
|
-
* <b>Note:</b> This format option is only allowed if the following conditions apply:
|
|
561
|
-
* <ul>
|
|
562
|
-
* <li>It has a value greater than 0.</li>
|
|
563
|
-
* <li>The <code>oFormatOptions.style</code> format option is <b>not</b> set to <code>"short"</code> or
|
|
564
|
-
* <code>"long"</code>.</li>
|
|
565
|
-
* </ul>
|
|
566
|
-
* @param {int} [oFormatOptions.decimals] defines the number of decimal digits
|
|
567
|
-
* @param {string} [oFormatOptions.decimalSeparator] defines the character used as decimal separator.
|
|
568
|
-
* Note: <code>decimalSeparator</code> must always be different from <code>groupingSeparator</code>.
|
|
569
|
-
* @param {null|number|string} [oFormatOptions.emptyString=NaN] since 1.30.0 defines what an empty string
|
|
570
|
-
* is parsed as, and what is formatted as an empty string. The allowed values are "" (empty string),
|
|
571
|
-
* NaN, <code>null</code>, or 0.
|
|
572
|
-
* The 'format' and 'parse' functions are done in a symmetric way. For example, when this
|
|
573
|
-
* parameter is set to NaN, an empty string is parsed as NaN, and NaN is formatted as an empty
|
|
574
|
-
* string.
|
|
575
|
-
* @param {int} [oFormatOptions.groupingBaseSize=3] defines the grouping base size in digits if
|
|
576
|
-
* it is different from the grouping size (e.g. Indian grouping)
|
|
577
|
-
* @param {boolean} [oFormatOptions.groupingEnabled=true] defines whether grouping is enabled
|
|
578
|
-
* (grouping separators are shown).
|
|
579
|
-
* <b>Note:</b> Grouping is disabled if the <code>groupingSize</code> format option is set to
|
|
580
|
-
* a non-positive value.
|
|
581
|
-
* @param {string} [oFormatOptions.groupingSeparator] defines the character used as grouping separator.
|
|
582
|
-
* Note: <code>groupingSeparator</code> must always be different from <code>decimalSeparator</code>.
|
|
583
|
-
* @param {int} [oFormatOptions.groupingSize=3] defines the grouping size in digits; the default
|
|
584
|
-
* is <code>3</code>.
|
|
585
|
-
* <b>Note:</b> If this format option is set to a non-positive value, grouping will be disabled entirely.
|
|
586
|
-
* @param {int} [oFormatOptions.maxFractionDigits=99] defines the maximum number of decimal digits
|
|
587
|
-
* @param {int} [oFormatOptions.maxIntegerDigits=99] defines the maximum number of non-decimal digits.
|
|
588
|
-
* If the number exceeds this maximum, e.g. 1e+120, "?" characters are shown instead of digits.
|
|
589
|
-
* @param {int} [oFormatOptions.minFractionDigits=0] defines the minimal number of decimal digits
|
|
590
|
-
* @param {int} [oFormatOptions.minIntegerDigits=1] defines the minimal number of non-decimal digits
|
|
591
|
-
* @param {string} [oFormatOptions.minusSign] defines the used minus symbol
|
|
592
|
-
* @param {boolean} [oFormatOptions.parseAsString=false] since 1.28.2 defines whether to output
|
|
593
|
-
* the string from the parse function in order to keep the precision for big numbers. Numbers
|
|
594
|
-
* in scientific notation are parsed back to standard notation. For example, "5e-3" is parsed
|
|
595
|
-
* to "0.005".
|
|
596
|
-
* @param {string} [oFormatOptions.pattern] CLDR number pattern which is used to format the number
|
|
597
|
-
* @param {string} [oFormatOptions.plusSign] defines the used plus symbol
|
|
598
|
-
* @param {int} [oFormatOptions.precision] The maximum number of digits in the formatted representation of a number;
|
|
599
|
-
* if the <code>precision</code> is less than the overall length of the number, its fractional part is truncated
|
|
600
|
-
* through rounding. As the <code>precision</code> only affects the rounding of a number, its integer part can
|
|
601
|
-
* retain more digits than defined by this parameter.
|
|
602
|
-
* <b>Example:</b> With a <code>precision</code> of 2, <code>234.567</code> is formatted to <code>235</code>.
|
|
603
|
-
* <b>Note:</b> The formatted output may differ depending on locale.
|
|
604
|
-
* @param {boolean} [oFormatOptions.preserveDecimals=false] Whether {@link #format} preserves
|
|
605
|
-
* decimal digits except trailing zeros in case there are more decimals than the
|
|
606
|
-
* <code>maxFractionDigits</code> format option allows.
|
|
607
|
-
* If decimals are not preserved, the formatted number is rounded to <code>maxFractionDigits</code>.
|
|
608
|
-
* @param {sap.ui.core.format.NumberFormat.RoundingMode} [oFormatOptions.roundingMode=HALF_AWAY_FROM_ZERO]
|
|
609
|
-
* Specifies the rounding behavior for discarding the digits after the maximum fraction digits
|
|
610
|
-
* defined by <code>maxFractionDigits</code>.
|
|
611
|
-
* This can be assigned
|
|
612
|
-
* <ul>
|
|
613
|
-
* <li>by value in {@link sap.ui.core.format.NumberFormat.RoundingMode RoundingMode},</li>
|
|
614
|
-
* <li>via a function that is used for rounding the number and takes two parameters: the number itself, and the
|
|
615
|
-
* number of decimal digits that should be reserved. <b>Using a function is deprecated since 1.121.0</b>;
|
|
616
|
-
* string based numbers are not rounded via this custom function.</li>
|
|
617
|
-
* </ul>
|
|
618
|
-
* @param {int} [oFormatOptions.shortDecimals] defines the number of decimal in the shortened format string. If this isn't specified, the 'decimals' options is used
|
|
619
|
-
* @param {int} [oFormatOptions.shortLimit] only use short number formatting for values above this limit
|
|
620
|
-
* @param {int} [oFormatOptions.shortRefNumber] since 1.40 specifies a number from which the scale factor for 'short' or 'long' style format is generated. The generated scale factor is
|
|
621
|
-
* used for all numbers which are formatted with this format instance. This option has effect only when the option 'style' is set to 'short' or 'long'. This option is by default set
|
|
622
|
-
* with <code>undefined</code> which means the scale factor is selected automatically for each number being formatted.
|
|
623
|
-
* @param {boolean} [oFormatOptions.showScale=true] since 1.40 specifies whether the scale factor is shown in the formatted number. This option takes effect only when the 'style' options is set to either 'short' or 'long'.
|
|
624
|
-
* @param {boolean} [oFormatOptions.strictGroupingValidation=false] whether the positions of grouping separators are validated. Space characters used as grouping separators are not validated.
|
|
625
|
-
* @param {string} [oFormatOptions.style=standard] defines the style of format. Valid values are
|
|
626
|
-
* 'short, 'long' or 'standard' (based on the CLDR decimalFormat). When set to 'short' or 'long',
|
|
627
|
-
* numbers are formatted into compact forms. When this option is set, the default value of the
|
|
628
|
-
* 'precision' option is set to 2. This can be changed by setting either min/maxFractionDigits,
|
|
629
|
-
* decimals, shortDecimals, or the 'precision' option itself.
|
|
630
901
|
* @param {sap.ui.core.Locale} [oLocale]
|
|
631
902
|
* The locale to get the formatter for; if no locale is given, a locale for the currently configured language is
|
|
632
903
|
* used; see {@link module:sap/base/i18n/Formatting.getLanguageTag Formatting.getLanguageTag}
|
|
@@ -664,76 +935,24 @@ NumberFormat.getFloatInstance = function (oFormatOptions, oLocale) {
|
|
|
664
935
|
* oFormat.format(1234); // "1.234"
|
|
665
936
|
* </pre>
|
|
666
937
|
*
|
|
667
|
-
* @param {
|
|
938
|
+
* @param {sap.ui.core.format.NumberFormat.IntegerFormatOptions} [oFormatOptions={
|
|
939
|
+
* emptyString: NaN,
|
|
940
|
+
* groupingBaseSize: 3,
|
|
941
|
+
* groupingEnabled: false,
|
|
942
|
+
* groupingSize: 3,
|
|
943
|
+
* maxFractionDigits: 0,
|
|
944
|
+
* maxIntegerDigits: 99,
|
|
945
|
+
* minFractionDigits: 0,
|
|
946
|
+
* minIntegerDigits: 1,
|
|
947
|
+
* parseAsString: false,
|
|
948
|
+
* preserveDecimals: false,
|
|
949
|
+
* roundingMode: "TOWARDS_ZERO",
|
|
950
|
+
* showScale: true,
|
|
951
|
+
* strictGroupingValidation: false,
|
|
952
|
+
* style: "standard"
|
|
953
|
+
* }]
|
|
954
|
+
* The option object, which supports the following parameters.
|
|
668
955
|
* If no options are given, default values according to the type and locale settings are used.
|
|
669
|
-
* @param {int} [oFormatOptions.decimalPadding] Not supported.
|
|
670
|
-
* @param {int} [oFormatOptions.decimals] defines the number of decimal digits
|
|
671
|
-
* @param {string} [oFormatOptions.decimalSeparator] defines the character used as decimal separator.
|
|
672
|
-
* Note: <code>decimalSeparator</code> must always be different from <code>groupingSeparator</code>.
|
|
673
|
-
* @param {null|number|string} [oFormatOptions.emptyString=NaN] since 1.30.0 defines what an empty string
|
|
674
|
-
* is parsed as, and what is formatted as an empty string. The allowed values are "" (empty string)
|
|
675
|
-
* NaN, <code>null</code>, or 0.
|
|
676
|
-
* The 'format' and 'parse' functions are done in a symmetric way. For example, when this
|
|
677
|
-
* parameter is set to NaN, an empty string is parsed as NaN, and NaN is formatted as an empty
|
|
678
|
-
* string.
|
|
679
|
-
* @param {int} [oFormatOptions.groupingBaseSize=3] defines the grouping base size in digits if
|
|
680
|
-
* it is different from the grouping size (e.g. Indian grouping)
|
|
681
|
-
* @param {boolean} [oFormatOptions.groupingEnabled=false] defines whether grouping is enabled
|
|
682
|
-
* (grouping separators are shown).
|
|
683
|
-
* <b>Note:</b> Grouping is disabled if the <code>groupingSize</code> format option is set to
|
|
684
|
-
* a non-positive value.
|
|
685
|
-
* @param {string} [oFormatOptions.groupingSeparator] defines the character used as grouping separator.
|
|
686
|
-
* Note: <code>groupingSeparator</code> must always be different from <code>decimalSeparator</code>.
|
|
687
|
-
* @param {int} [oFormatOptions.groupingSize=3] defines the grouping size in digits; the default
|
|
688
|
-
* is <code>3</code>.
|
|
689
|
-
* <b>Note:</b> If this format option is set to a non-positive value, grouping will be disabled entirely.
|
|
690
|
-
* @param {int} [oFormatOptions.maxFractionDigits=0] defines the maximum number of decimal digits
|
|
691
|
-
* @param {int} [oFormatOptions.maxIntegerDigits=99] defines the maximum number of non-decimal digits.
|
|
692
|
-
* If the number exceeds this maximum, e.g. 1e+120, "?" characters are shown instead of digits.
|
|
693
|
-
* @param {int} [oFormatOptions.minFractionDigits=0] defines the minimal number of decimal digits
|
|
694
|
-
* @param {int} [oFormatOptions.minIntegerDigits=1] defines the minimal number of non-decimal digits
|
|
695
|
-
* @param {string} [oFormatOptions.minusSign] defines the used minus symbol
|
|
696
|
-
* @param {boolean} [oFormatOptions.parseAsString=false] since 1.28.2 defines whether to output
|
|
697
|
-
* the string from the parse function in order to keep the precision for big numbers. Numbers
|
|
698
|
-
* in scientific notation are parsed back to standard notation. For example, "5e+3" is parsed
|
|
699
|
-
* to "5000".
|
|
700
|
-
* @param {string} [oFormatOptions.pattern] CLDR number pattern which is used to format the number
|
|
701
|
-
* @param {string} [oFormatOptions.plusSign] defines the used plus symbol
|
|
702
|
-
* @param {int} [oFormatOptions.precision] <b>Note:</b> Only considered if the number format leads to a
|
|
703
|
-
* representation with decimal places, e.g. if the option <code>style: "short"</code> is set.
|
|
704
|
-
* The maximum number of digits in the formatted representation of a number; if the <code>precision</code> is
|
|
705
|
-
* less than the overall length of the number, its fractional part is truncated through rounding.
|
|
706
|
-
* As the <code>precision</code> only affects the rounding of a number, its integer part can retain more digits
|
|
707
|
-
* than defined by this parameter.
|
|
708
|
-
* <b>Example:</b> With a <code>precision</code> of 2 and <code>style: "short"</code>,
|
|
709
|
-
* <code>234567</code> is formatted to <code>"235K"</code>.
|
|
710
|
-
* <b>Note:</b> The formatted output may differ depending on locale.
|
|
711
|
-
* @param {boolean} [oFormatOptions.preserveDecimals=false] Whether {@link #format} preserves
|
|
712
|
-
* decimal digits except trailing zeros in case there are more decimals than the
|
|
713
|
-
* <code>maxFractionDigits</code> format option allows.
|
|
714
|
-
* If decimals are not preserved, the formatted number is rounded to <code>maxFractionDigits</code>.
|
|
715
|
-
* @param {sap.ui.core.format.NumberFormat.RoundingMode} [oFormatOptions.roundingMode=TOWARDS_ZERO]
|
|
716
|
-
* Specifies the rounding behavior for discarding the digits after the maximum fraction digits
|
|
717
|
-
* defined by <code>maxFractionDigits</code>.
|
|
718
|
-
* This can be assigned
|
|
719
|
-
* <ul>
|
|
720
|
-
* <li>by value in {@link sap.ui.core.format.NumberFormat.RoundingMode RoundingMode},</li>
|
|
721
|
-
* <li>via a function that is used for rounding the number and takes two parameters: the number itself, and the
|
|
722
|
-
* number of decimal digits that should be reserved. <b>Using a function is deprecated since 1.121.0</b>;
|
|
723
|
-
* string based numbers are not rounded via this custom function.</li>
|
|
724
|
-
* </ul>
|
|
725
|
-
* @param {int} [oFormatOptions.shortDecimals] defines the number of decimal in the shortened format string. If this isn't specified, the 'decimals' options is used
|
|
726
|
-
* @param {int} [oFormatOptions.shortLimit] only use short number formatting for values above this limit
|
|
727
|
-
* @param {int} [oFormatOptions.shortRefNumber] since 1.40 specifies a number from which the scale factor for 'short' or 'long' style format is generated. The generated scale factor is
|
|
728
|
-
* used for all numbers which are formatted with this format instance. This option has effect only when the option 'style' is set to 'short' or 'long'. This option is by default set
|
|
729
|
-
* with <code>undefined</code> which means the scale factor is selected automatically for each number being formatted.
|
|
730
|
-
* @param {boolean} [oFormatOptions.showScale=true] since 1.40 specifies whether the scale factor is shown in the formatted number. This option takes effect only when the 'style' options is set to either 'short' or 'long'.
|
|
731
|
-
* @param {boolean} [oFormatOptions.strictGroupingValidation=false] whether the positions of grouping separators are validated. Space characters used as grouping separators are not validated.
|
|
732
|
-
* @param {string} [oFormatOptions.style=standard] defines the style of format. Valid values are
|
|
733
|
-
* 'short, 'long' or 'standard' (based on the CLDR decimalFormat). When set to 'short' or 'long',
|
|
734
|
-
* numbers are formatted into compact forms. When this option is set, the default value of the
|
|
735
|
-
* 'precision' option is set to 2. This can be changed by setting either min/maxFractionDigits,
|
|
736
|
-
* decimals, shortDecimals, or the 'precision' option itself.
|
|
737
956
|
* @param {sap.ui.core.Locale} [oLocale]
|
|
738
957
|
* The locale to get the formatter for; if no locale is given, a locale for the currently configured language is
|
|
739
958
|
* used; see {@link module:sap/base/i18n/Formatting.getLanguageTag Formatting.getLanguageTag}
|
|
@@ -805,105 +1024,28 @@ NumberFormat.getIntegerInstance = function (oFormatOptions, oLocale) {
|
|
|
805
1024
|
* oFormat.format(777.888, "Bitcoin"); // "Bitcoin 777.89"
|
|
806
1025
|
* </pre>
|
|
807
1026
|
*
|
|
808
|
-
* @param {
|
|
1027
|
+
* @param {sap.ui.core.format.NumberFormat.CurrencyFormatOptions} [oFormatOptions={
|
|
1028
|
+
* currencyCode: true,
|
|
1029
|
+
* currencyContext: "standard",
|
|
1030
|
+
* emptyString: NaN,
|
|
1031
|
+
* groupingBaseSize: 3,
|
|
1032
|
+
* groupingEnabled: true,
|
|
1033
|
+
* groupingSize: 3,
|
|
1034
|
+
* maxFractionDigits: 99,
|
|
1035
|
+
* maxIntegerDigits: 99,
|
|
1036
|
+
* minFractionDigits: 0,
|
|
1037
|
+
* minIntegerDigits: 1,
|
|
1038
|
+
* parseAsString: false,
|
|
1039
|
+
* preserveDecimals: false,
|
|
1040
|
+
* roundingMode: "HALF_AWAY_FROM_ZERO",
|
|
1041
|
+
* showMeasure: true,
|
|
1042
|
+
* showNumber: true,
|
|
1043
|
+
* showScale: true,
|
|
1044
|
+
* strictGroupingValidation: false,
|
|
1045
|
+
* style: "standard"
|
|
1046
|
+
* }]
|
|
1047
|
+
* The option object, which supports the following parameters.
|
|
809
1048
|
* If no options are given, default values according to the type and locale settings are used.
|
|
810
|
-
* @param {boolean} [oFormatOptions.currencyCode=true] defines whether the currency is shown as
|
|
811
|
-
* a code in currency format. The currency symbol is displayed when this option is set to
|
|
812
|
-
* <code>false</code> and a symbol has been defined for the given currency code.
|
|
813
|
-
* @param {string} [oFormatOptions.currencyContext=standard] can be set either to 'standard'
|
|
814
|
-
* (the default value) or to 'accounting' for an accounting-specific currency display
|
|
815
|
-
* @param {Object<string,object>} [oFormatOptions.customCurrencies] defines a set of custom currencies exclusive to this NumberFormat instance.
|
|
816
|
-
* Custom currencies must not only consist of digits.
|
|
817
|
-
* If custom currencies are defined on the instance, no other currencies can be formatted and parsed by this instance.
|
|
818
|
-
* Globally available custom currencies can be added via the global configuration.
|
|
819
|
-
* See the above examples.
|
|
820
|
-
* See also {@link module:sap/base/i18n/Formatting.setCustomCurrencies Formatting.setCustomCurrencies} and
|
|
821
|
-
* {@link module:sap/base/i18n/Formatting.addCustomCurrencies Formatting.addCustomCurrencies}.
|
|
822
|
-
* @param {int} [oFormatOptions.decimalPadding]
|
|
823
|
-
* The target length of places after the decimal separator; if the number has fewer decimal places than given in
|
|
824
|
-
* this option, it is padded with whitespaces at the end up to the target length. An additional whitespace
|
|
825
|
-
* character for the decimal separator is added for a number without any decimals.
|
|
826
|
-
* <b>Note:</b> This format option is only allowed if the following conditions apply:
|
|
827
|
-
* <ul>
|
|
828
|
-
* <li>It has a value greater than 0.</li>
|
|
829
|
-
* <li>The <code>FormatOptions.showMeasure</code> format option is set to <code>false</code>.</li>
|
|
830
|
-
* <li>The <code>oFormatOptions.style</code> format option is <b>not</b> set to <code>"short"</code> or
|
|
831
|
-
* <code>"long"</code>.</li>
|
|
832
|
-
* </ul>
|
|
833
|
-
* @param {int} [oFormatOptions.decimals] defines the number of decimal digits
|
|
834
|
-
* @param {string} [oFormatOptions.decimalSeparator] defines the character used as decimal separator.
|
|
835
|
-
* Note: <code>decimalSeparator</code> must always be different from <code>groupingSeparator</code>.
|
|
836
|
-
* @param {null|number|string} [oFormatOptions.emptyString=NaN] since 1.30.0 defines what an empty string
|
|
837
|
-
* is parsed as, and what is formatted as an empty string. The allowed values are "" (empty string),
|
|
838
|
-
* NaN, <code>null</code>, or 0.
|
|
839
|
-
* The 'format' and 'parse' functions are done in a symmetric way. For example, when this
|
|
840
|
-
* parameter is set to NaN, an empty string is parsed as [NaN, undefined], and NaN is
|
|
841
|
-
* formatted as an empty string.
|
|
842
|
-
* @param {int} [oFormatOptions.groupingBaseSize=3] defines the grouping base size in digits if
|
|
843
|
-
* it is different from the grouping size (e.g. Indian grouping)
|
|
844
|
-
* @param {boolean} [oFormatOptions.groupingEnabled=true] defines whether grouping is enabled
|
|
845
|
-
* (grouping separators are shown).
|
|
846
|
-
* <b>Note:</b> Grouping is disabled if the <code>groupingSize</code> format option is set to
|
|
847
|
-
* a non-positive value.
|
|
848
|
-
* @param {string} [oFormatOptions.groupingSeparator] defines the character used as grouping separator.
|
|
849
|
-
* Note: <code>groupingSeparator</code> must always be different from <code>decimalSeparator</code>.
|
|
850
|
-
* @param {int} [oFormatOptions.groupingSize=3] defines the grouping size in digits; the default
|
|
851
|
-
* is <code>3</code>.
|
|
852
|
-
* <b>Note:</b> If this format option is set to a non-positive value, grouping will be disabled entirely.
|
|
853
|
-
* @param {int} [oFormatOptions.maxFractionDigits=99] defines the maximum number of decimal digits
|
|
854
|
-
* @param {int} [oFormatOptions.maxIntegerDigits=99] defines the maximum number of non-decimal digits.
|
|
855
|
-
* If the number exceeds this maximum, e.g. 1e+120, "?" characters are shown instead of digits.
|
|
856
|
-
* @param {int} [oFormatOptions.minFractionDigits=0] Deprecated as of 1.130; this format option does not have
|
|
857
|
-
* an effect on currency formats since decimals can always be determined, either through the given format options,
|
|
858
|
-
* custom currencies or the CLDR
|
|
859
|
-
* @param {int} [oFormatOptions.minIntegerDigits=1] defines the minimal number of non-decimal digits
|
|
860
|
-
* @param {string} [oFormatOptions.minusSign] defines the used minus symbol
|
|
861
|
-
* @param {boolean} [oFormatOptions.parseAsString=false] since 1.28.2 defines whether to output
|
|
862
|
-
* the string from the parse function in order to keep the precision for big numbers. Numbers
|
|
863
|
-
* in scientific notation are parsed back to standard notation. For example, "5e-3" is parsed
|
|
864
|
-
* to "0.005".
|
|
865
|
-
* @param {string} [oFormatOptions.pattern] CLDR number pattern which is used to format the number
|
|
866
|
-
* @param {string} [oFormatOptions.plusSign] defines the used plus symbol
|
|
867
|
-
* @param {boolean} [oFormatOptions.preserveDecimals=false] Whether {@link #format} preserves
|
|
868
|
-
* decimal digits except trailing zeros in case there are more decimals than the
|
|
869
|
-
* <code>maxFractionDigits</code> format option allows.
|
|
870
|
-
* If decimals are not preserved, the formatted number is rounded to <code>maxFractionDigits</code>.
|
|
871
|
-
* @param {sap.ui.core.format.NumberFormat.RoundingMode} [oFormatOptions.roundingMode=HALF_AWAY_FROM_ZERO]
|
|
872
|
-
* Specifies the rounding behavior for discarding the digits after the maximum fraction digits
|
|
873
|
-
* defined by <code>maxFractionDigits</code>.
|
|
874
|
-
* This can be assigned
|
|
875
|
-
* <ul>
|
|
876
|
-
* <li>by value in {@link sap.ui.core.format.NumberFormat.RoundingMode RoundingMode},</li>
|
|
877
|
-
* <li>via a function that is used for rounding the number and takes two parameters: the number itself, and the
|
|
878
|
-
* number of decimal digits that should be reserved. <b>Using a function is deprecated since 1.121.0</b>;
|
|
879
|
-
* string based numbers are not rounded via this custom function.</li>
|
|
880
|
-
* </ul>
|
|
881
|
-
* @param {int} [oFormatOptions.shortDecimals] defines the number of decimal in the shortened format string. If this isn't specified, the 'decimals' options is used
|
|
882
|
-
* @param {int} [oFormatOptions.shortLimit] only use short number formatting for values above this limit
|
|
883
|
-
* @param {int} [oFormatOptions.shortRefNumber] since 1.40 specifies a number from which the scale factor for 'short' or 'long' style format is generated. The generated scale factor is
|
|
884
|
-
* used for all numbers which are formatted with this format instance. This option has effect only when the option 'style' is set to 'short' or 'long'. This option is by default set
|
|
885
|
-
* with <code>undefined</code> which means the scale factor is selected automatically for each number being formatted.
|
|
886
|
-
* @param {boolean} [oFormatOptions.showMeasure=true] defines whether the currency code/symbol is shown in the formatted string,
|
|
887
|
-
* e.g. true: "1.00 EUR", false: "1.00" for locale "en"
|
|
888
|
-
* If both <code>showMeasure</code> and <code>showNumber</code> are false, an empty string is returned
|
|
889
|
-
* @param {boolean} [oFormatOptions.showNumber=true] defines whether the number is shown as part of the result string,
|
|
890
|
-
* e.g. 1 EUR for locale "en"
|
|
891
|
-
* <code>NumberFormat.getCurrencyInstance({showNumber:true}).format(1, "EUR"); // "1.00 EUR"</code>
|
|
892
|
-
* <code>NumberFormat.getCurrencyInstance({showNumber:false}).format(1, "EUR"); // "EUR"</code>
|
|
893
|
-
* If both <code>showMeasure</code> and <code>showNumber</code> are false, an empty string is returned
|
|
894
|
-
* @param {boolean} [oFormatOptions.showScale=true] since 1.40 specifies whether the scale factor is shown in the formatted number.
|
|
895
|
-
* This option takes effect only when the 'style' options is set to either 'short' or 'long'.
|
|
896
|
-
* @param {boolean} [oFormatOptions.strictGroupingValidation=false] whether the positions of grouping separators are validated. Space characters used as grouping separators are not validated.
|
|
897
|
-
* @param {string} [oFormatOptions.style=standard] defines the style of format. Valid values are
|
|
898
|
-
* 'short, 'long' or 'standard' (based on the CLDR decimalFormat). When set to 'short' or 'long',
|
|
899
|
-
* numbers are formatted into the 'short' form only. When this option is set, the default value of the
|
|
900
|
-
* 'precision' option is set to 2. This can be changed by setting either min/maxFractionDigits,
|
|
901
|
-
* decimals, shortDecimals, or the 'precision' option itself.
|
|
902
|
-
* @param {boolean} [oFormatOptions.trailingCurrencyCode] overrides the global configuration
|
|
903
|
-
* value {@link module:sap/base/i18n/Formatting.getTrailingCurrencyCode Formatting.getTrailingCurrencyCode},
|
|
904
|
-
* which has a default value of <code>true</>.
|
|
905
|
-
* This is ignored if <code>oFormatOptions.currencyCode</code> is set to <code>false</code>,
|
|
906
|
-
* or if <code>oFormatOptions.pattern</code> is supplied.
|
|
907
1049
|
* @param {sap.ui.core.Locale} [oLocale]
|
|
908
1050
|
* The locale to get the formatter for; if no locale is given, a locale for the currently configured language is
|
|
909
1051
|
* used; see {@link module:sap/base/i18n/Formatting.getLanguageTag Formatting.getLanguageTag}
|
|
@@ -944,109 +1086,26 @@ NumberFormat.getCurrencyInstance = function (oFormatOptions, oLocale) {
|
|
|
944
1086
|
* default value.
|
|
945
1087
|
* </p>
|
|
946
1088
|
*
|
|
947
|
-
* @param {
|
|
1089
|
+
* @param {sap.ui.core.format.NumberFormat.UnitFormatOptions} [oFormatOptions={
|
|
1090
|
+
* emptyString: NaN,
|
|
1091
|
+
* groupingBaseSize: 3,
|
|
1092
|
+
* groupingEnabled: true,
|
|
1093
|
+
* groupingSize: 3,
|
|
1094
|
+
* maxFractionDigits: 99,
|
|
1095
|
+
* maxIntegerDigits: 99,
|
|
1096
|
+
* minFractionDigits: 0,
|
|
1097
|
+
* minIntegerDigits: 1,
|
|
1098
|
+
* parseAsString: false,
|
|
1099
|
+
* preserveDecimals: false,
|
|
1100
|
+
* roundingMode: "HALF_AWAY_FROM_ZERO",
|
|
1101
|
+
* showMeasure: true,
|
|
1102
|
+
* showNumber: true,
|
|
1103
|
+
* showScale: true,
|
|
1104
|
+
* strictGroupingValidation: false,
|
|
1105
|
+
* style: "standard"
|
|
1106
|
+
* }]
|
|
1107
|
+
* The option object, which supports the following parameters.
|
|
948
1108
|
* If no options are given, default values according to the type and locale settings are used.
|
|
949
|
-
* @param {array} [oFormatOptions.allowedUnits] defines the allowed units for formatting and parsing, e.g. ["size-meter", "volume-liter", ...]
|
|
950
|
-
* @param {Object<string,object>} [oFormatOptions.customUnits] defines a set of custom units, e.g.
|
|
951
|
-
* {"electric-inductance": {
|
|
952
|
-
* "displayName": "henry",
|
|
953
|
-
* "unitPattern-count-one": "{0} H",
|
|
954
|
-
* "unitPattern-count-other": "{0} H",
|
|
955
|
-
* "perUnitPattern": "{0}/H",
|
|
956
|
-
* "decimals": 2,
|
|
957
|
-
* "precision": 4
|
|
958
|
-
* }}
|
|
959
|
-
* @param {int} [oFormatOptions.decimalPadding]
|
|
960
|
-
* The target length of places after the decimal separator; if the number has fewer decimal places than given in
|
|
961
|
-
* this option, it is padded with whitespaces at the end up to the target length. An additional whitespace
|
|
962
|
-
* character for the decimal separator is added for a number without any decimals.
|
|
963
|
-
* <b>Note:</b> This format option is only allowed if the following conditions apply:
|
|
964
|
-
* <ul>
|
|
965
|
-
* <li>It has a value greater than 0.</li>
|
|
966
|
-
* <li>The <code>FormatOptions.showMeasure</code> format option is set to <code>false</code>.</li>
|
|
967
|
-
* <li>The <code>oFormatOptions.style</code> format option is <b>not</b> set to <code>"short"</code> or
|
|
968
|
-
* <code>"long"</code>.</li>
|
|
969
|
-
* </ul>
|
|
970
|
-
* @param {int} [oFormatOptions.decimals] defines the number of decimal digits
|
|
971
|
-
* @param {string} [oFormatOptions.decimalSeparator] defines the character used as decimal separator.
|
|
972
|
-
* Note: <code>decimalSeparator</code> must always be different from <code>groupingSeparator</code>.
|
|
973
|
-
* @param {null|number|string} [oFormatOptions.emptyString=NaN] since 1.30.0 defines what an empty string
|
|
974
|
-
* is parsed as, and what is formatted as an empty string. The allowed values are "" (empty string),
|
|
975
|
-
* NaN, <code>null</code>, or 0.
|
|
976
|
-
* The 'format' and 'parse' functions are done in a symmetric way. For example, when this
|
|
977
|
-
* parameter is set to NaN, an empty string is parsed as [NaN, undefined], and NaN is
|
|
978
|
-
* formatted as an empty string.
|
|
979
|
-
* @param {int} [oFormatOptions.groupingBaseSize=3] defines the grouping base size in digits if
|
|
980
|
-
* it is different from the grouping size (e.g. Indian grouping)
|
|
981
|
-
* @param {boolean} [oFormatOptions.groupingEnabled=true] defines whether grouping is enabled
|
|
982
|
-
* (grouping separators are shown).
|
|
983
|
-
* <b>Note:</b> Grouping is disabled if the <code>groupingSize</code> format option is set to
|
|
984
|
-
* a non-positive value.
|
|
985
|
-
* @param {string} [oFormatOptions.groupingSeparator] defines the character used as grouping separator.
|
|
986
|
-
* Note: <code>groupingSeparator</code> must always be different from <code>decimalSeparator</code>.
|
|
987
|
-
* @param {int} [oFormatOptions.groupingSize=3] defines the grouping size in digits; the default
|
|
988
|
-
* is <code>3</code>.
|
|
989
|
-
* <b>Note:</b> If this format option is set to a non-positive value, grouping will be disabled entirely.
|
|
990
|
-
* @param {int} [oFormatOptions.maxFractionDigits=99] defines the maximum number of decimal digits
|
|
991
|
-
* @param {int} [oFormatOptions.maxIntegerDigits=99] defines the maximum number of non-decimal digits.
|
|
992
|
-
* If the number exceeds this maximum, e.g. 1e+120, "?" characters are shown instead of digits.
|
|
993
|
-
* @param {int} [oFormatOptions.minFractionDigits=0] defines the minimal number of decimal digits
|
|
994
|
-
* @param {int} [oFormatOptions.minIntegerDigits=1] defines the minimal number of non-decimal digits
|
|
995
|
-
* @param {string} [oFormatOptions.minusSign] defines the used minus symbol
|
|
996
|
-
* @param {boolean} [oFormatOptions.parseAsString=false] since 1.28.2 defines whether to output
|
|
997
|
-
* the string from the parse function in order to keep the precision for big numbers. Numbers
|
|
998
|
-
* in scientific notation are parsed back to standard notation. For example, "5e-3" is parsed
|
|
999
|
-
* to "0.005".
|
|
1000
|
-
* @param {string} [oFormatOptions.pattern] CLDR number pattern which is used to format the number
|
|
1001
|
-
* @param {string} [oFormatOptions.plusSign] defines the used plus symbol
|
|
1002
|
-
* @param {int} [oFormatOptions.precision] The maximum number of digits in the formatted representation of a number;
|
|
1003
|
-
* if the <code>precision</code> is less than the overall length of the number, its fractional part is truncated
|
|
1004
|
-
* through rounding. As the <code>precision</code> only affects the rounding of a number, its integer part can
|
|
1005
|
-
* retain more digits than defined by this parameter.
|
|
1006
|
-
* <b>Example:</b> With a <code>precision</code> of 2, the parameters <code>"234.567", "mass-kilogram"</code> are
|
|
1007
|
-
* formatted to <code>"235 kg"</code>.
|
|
1008
|
-
* <b>Note:</b> The formatted output may differ depending on locale.
|
|
1009
|
-
* @param {boolean} [oFormatOptions.preserveDecimals=false] Whether {@link #format} preserves
|
|
1010
|
-
* decimal digits except trailing zeros in case there are more decimals than the
|
|
1011
|
-
* <code>maxFractionDigits</code> format option allows.
|
|
1012
|
-
* If decimals are not preserved, the formatted number is rounded to <code>maxFractionDigits</code>.
|
|
1013
|
-
* @param {sap.ui.core.format.NumberFormat.RoundingMode} [oFormatOptions.roundingMode=HALF_AWAY_FROM_ZERO]
|
|
1014
|
-
* Specifies the rounding behavior for discarding the digits after the maximum fraction digits
|
|
1015
|
-
* defined by <code>maxFractionDigits</code>.
|
|
1016
|
-
* This can be assigned
|
|
1017
|
-
* <ul>
|
|
1018
|
-
* <li>by value in {@link sap.ui.core.format.NumberFormat.RoundingMode RoundingMode},</li>
|
|
1019
|
-
* <li>via a function that is used for rounding the number and takes two parameters: the number itself, and the
|
|
1020
|
-
* number of decimal digits that should be reserved. <b>Using a function is deprecated since 1.121.0</b>;
|
|
1021
|
-
* string based numbers are not rounded via this custom function.</li>
|
|
1022
|
-
* </ul>
|
|
1023
|
-
* @param {int} [oFormatOptions.shortDecimals] defines the number of decimals in the shortened
|
|
1024
|
-
* format string. If this option isn't specified, the 'decimals' option is used instead.
|
|
1025
|
-
* @param {int} [oFormatOptions.shortLimit] defines a limit above which only short number formatting is used
|
|
1026
|
-
* @param {int} [oFormatOptions.shortRefNumber] since 1.40 specifies a number from which the
|
|
1027
|
-
* scale factor for the 'short' or 'long' style format is generated. The generated scale
|
|
1028
|
-
* factor is used for all numbers which are formatted with this format instance. This option
|
|
1029
|
-
* only takes effect when the 'style' option is set to 'short' or 'long'. This option is
|
|
1030
|
-
* set to <code>undefined</code> by default, which means that the scale factor is selected
|
|
1031
|
-
* automatically for each number being formatted.
|
|
1032
|
-
* @param {boolean} [oFormatOptions.showMeasure=true] defines whether the unit of measure is shown in the formatted string,
|
|
1033
|
-
* e.g. for input 1 and "duration-day" true: "1 day", false: "1".
|
|
1034
|
-
* If both <code>showMeasure</code> and <code>showNumber</code> are false, an empty string is returned
|
|
1035
|
-
* @param {boolean} [oFormatOptions.showNumber=true] defines whether the number is shown as part of the result string,
|
|
1036
|
-
* e.g. 1 day for locale "en"
|
|
1037
|
-
* <code>NumberFormat.getUnitInstance({showNumber:true}).format(1, "duration-day"); // "1 day"</code>
|
|
1038
|
-
* <code>NumberFormat.getUnitInstance({showNumber:false}).format(1, "duration-day"); // "day"</code>
|
|
1039
|
-
* e.g. 2 days for locale "en"
|
|
1040
|
-
* <code>NumberFormat.getUnitInstance({showNumber:true}).format(2, "duration-day"); // "2 days"</code>
|
|
1041
|
-
* <code>NumberFormat.getUnitInstance({showNumber:false}).format(2, "duration-day"); // "days"</code>
|
|
1042
|
-
* If both <code>showMeasure</code> and <code>showNumber</code> are false, an empty string is returned
|
|
1043
|
-
* @param {boolean} [oFormatOptions.showScale=true] since 1.40 specifies whether the scale factor is shown in the formatted number. This option takes effect only when the 'style' options is set to either 'short' or 'long'.
|
|
1044
|
-
* @param {boolean} [oFormatOptions.strictGroupingValidation=false] whether the positions of grouping separators are validated. Space characters used as grouping separators are not validated.
|
|
1045
|
-
* @param {string} [oFormatOptions.style=standard] defines the style of format. Valid values are
|
|
1046
|
-
* 'short, 'long' or 'standard' (based on the CLDR decimalFormat). When set to 'short' or 'long',
|
|
1047
|
-
* numbers are formatted into compact forms. When this option is set, the default value of the
|
|
1048
|
-
* 'precision' option is set to 2. This can be changed by setting either min/maxFractionDigits,
|
|
1049
|
-
* decimals, shortDecimals, or the 'precision' option itself.
|
|
1050
1109
|
* @param {sap.ui.core.Locale} [oLocale]
|
|
1051
1110
|
* The locale to get the formatter for; if no locale is given, a locale for the currently configured language is
|
|
1052
1111
|
* used; see {@link module:sap/base/i18n/Formatting.getLanguageTag Formatting.getLanguageTag}
|