1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
|
/*
* Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/Intl/AbstractOperations.h>
#include <LibJS/Runtime/Intl/NumberFormat.h>
#include <LibUnicode/CurrencyCode.h>
#include <LibUnicode/Locale.h>
namespace JS::Intl {
Vector<StringView> const& NumberFormat::relevant_extension_keys()
{
// 15.3.3 Internal slots, https://tc39.es/ecma402/#sec-intl.numberformat-internal-slots
// The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ».
static Vector<StringView> relevant_extension_keys { "nu"sv };
return relevant_extension_keys;
}
// 15 NumberFormat Objects, https://tc39.es/ecma402/#numberformat-objects
NumberFormat::NumberFormat(Object& prototype)
: Object(prototype)
{
}
void NumberFormat::set_style(StringView style)
{
if (style == "decimal"sv)
m_style = Style::Decimal;
else if (style == "percent"sv)
m_style = Style::Percent;
else if (style == "currency"sv)
m_style = Style::Currency;
else if (style == "unit"sv)
m_style = Style::Unit;
else
VERIFY_NOT_REACHED();
}
StringView NumberFormat::style_string() const
{
switch (m_style) {
case Style::Decimal:
return "decimal"sv;
case Style::Percent:
return "percent"sv;
case Style::Currency:
return "currency"sv;
case Style::Unit:
return "unit"sv;
default:
VERIFY_NOT_REACHED();
}
}
void NumberFormat::set_currency_display(StringView currency_display)
{
if (currency_display == "code"sv)
m_currency_display = CurrencyDisplay::Code;
else if (currency_display == "symbol"sv)
m_currency_display = CurrencyDisplay::Symbol;
else if (currency_display == "narrowSymbol"sv)
m_currency_display = CurrencyDisplay::NarrowSymbol;
else if (currency_display == "name"sv)
m_currency_display = CurrencyDisplay::Name;
else
VERIFY_NOT_REACHED();
}
StringView NumberFormat::currency_display_string() const
{
VERIFY(m_currency_display.has_value());
switch (*m_currency_display) {
case CurrencyDisplay::Code:
return "code"sv;
case CurrencyDisplay::Symbol:
return "symbol"sv;
case CurrencyDisplay::NarrowSymbol:
return "narrowSymbol"sv;
case CurrencyDisplay::Name:
return "name"sv;
default:
VERIFY_NOT_REACHED();
}
}
void NumberFormat::set_currency_sign(StringView currency_sign)
{
if (currency_sign == "standard"sv)
m_currency_sign = CurrencySign::Standard;
else if (currency_sign == "accounting"sv)
m_currency_sign = CurrencySign::Accounting;
else
VERIFY_NOT_REACHED();
}
StringView NumberFormat::currency_sign_string() const
{
VERIFY(m_currency_sign.has_value());
switch (*m_currency_sign) {
case CurrencySign::Standard:
return "standard"sv;
case CurrencySign::Accounting:
return "accounting"sv;
default:
VERIFY_NOT_REACHED();
}
}
void NumberFormat::set_unit_display(StringView unit_display)
{
if (unit_display == "short"sv)
m_unit_display = UnitDisplay::Short;
else if (unit_display == "narrow"sv)
m_unit_display = UnitDisplay::Narrow;
else if (unit_display == "long"sv)
m_unit_display = UnitDisplay::Long;
else
VERIFY_NOT_REACHED();
}
StringView NumberFormat::unit_display_string() const
{
VERIFY(m_unit_display.has_value());
switch (*m_unit_display) {
case UnitDisplay::Short:
return "short"sv;
case UnitDisplay::Narrow:
return "narrow"sv;
case UnitDisplay::Long:
return "long"sv;
default:
VERIFY_NOT_REACHED();
}
}
StringView NumberFormat::rounding_type_string() const
{
switch (m_rounding_type) {
case RoundingType::SignificantDigits:
return "significantDigits"sv;
case RoundingType::FractionDigits:
return "fractionDigits"sv;
case RoundingType::CompactRounding:
return "compactRounding"sv;
default:
VERIFY_NOT_REACHED();
}
}
void NumberFormat::set_notation(StringView notation)
{
if (notation == "standard"sv)
m_notation = Notation::Standard;
else if (notation == "scientific"sv)
m_notation = Notation::Scientific;
else if (notation == "engineering"sv)
m_notation = Notation::Engineering;
else if (notation == "compact"sv)
m_notation = Notation::Compact;
else
VERIFY_NOT_REACHED();
}
StringView NumberFormat::notation_string() const
{
switch (m_notation) {
case Notation::Standard:
return "standard"sv;
case Notation::Scientific:
return "scientific"sv;
case Notation::Engineering:
return "engineering"sv;
case Notation::Compact:
return "compact"sv;
default:
VERIFY_NOT_REACHED();
}
}
void NumberFormat::set_compact_display(StringView compact_display)
{
if (compact_display == "short"sv)
m_compact_display = CompactDisplay::Short;
else if (compact_display == "long"sv)
m_compact_display = CompactDisplay::Long;
else
VERIFY_NOT_REACHED();
}
StringView NumberFormat::compact_display_string() const
{
VERIFY(m_compact_display.has_value());
switch (*m_compact_display) {
case CompactDisplay::Short:
return "short"sv;
case CompactDisplay::Long:
return "long"sv;
default:
VERIFY_NOT_REACHED();
}
}
void NumberFormat::set_sign_display(StringView sign_display)
{
if (sign_display == "auto"sv)
m_sign_display = SignDisplay::Auto;
else if (sign_display == "never"sv)
m_sign_display = SignDisplay::Never;
else if (sign_display == "always"sv)
m_sign_display = SignDisplay::Always;
else if (sign_display == "exceptZero"sv)
m_sign_display = SignDisplay::ExceptZero;
else
VERIFY_NOT_REACHED();
}
StringView NumberFormat::sign_display_string() const
{
switch (m_sign_display) {
case SignDisplay::Auto:
return "auto"sv;
case SignDisplay::Never:
return "never"sv;
case SignDisplay::Always:
return "always"sv;
case SignDisplay::ExceptZero:
return "exceptZero"sv;
default:
VERIFY_NOT_REACHED();
}
}
// 15.1.1 SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation ), https://tc39.es/ecma402/#sec-setnfdigitoptions
void set_number_format_digit_options(GlobalObject& global_object, NumberFormat& intl_object, Object const& options, int default_min_fraction_digits, int default_max_fraction_digits, NumberFormat::Notation notation)
{
auto& vm = global_object.vm();
// 1. Assert: Type(intlObj) is Object.
// 2. Assert: Type(options) is Object.
// 3. Assert: Type(mnfdDefault) is Number.
// 4. Assert: Type(mxfdDefault) is Number.
// 5. Let mnid be ? GetNumberOption(options, "minimumIntegerDigits,", 1, 21, 1).
auto min_integer_digits = get_number_option(global_object, options, vm.names.minimumIntegerDigits, 1, 21, 1);
if (vm.exception())
return;
// 6. Let mnfd be ? Get(options, "minimumFractionDigits").
auto min_fraction_digits = options.get(vm.names.minimumFractionDigits);
if (vm.exception())
return;
// 7. Let mxfd be ? Get(options, "maximumFractionDigits").
auto max_fraction_digits = options.get(vm.names.maximumFractionDigits);
if (vm.exception())
return;
// 8. Let mnsd be ? Get(options, "minimumSignificantDigits").
auto min_significant_digits = options.get(vm.names.minimumSignificantDigits);
if (vm.exception())
return;
// 9. Let mxsd be ? Get(options, "maximumSignificantDigits").
auto max_significant_digits = options.get(vm.names.maximumSignificantDigits);
if (vm.exception())
return;
// 10. Set intlObj.[[MinimumIntegerDigits]] to mnid.
intl_object.set_min_integer_digits(*min_integer_digits);
// 11. If mnsd is not undefined or mxsd is not undefined, then
if (!min_significant_digits.is_undefined() || !max_significant_digits.is_undefined()) {
// a. Set intlObj.[[RoundingType]] to significantDigits.
intl_object.set_rounding_type(NumberFormat::RoundingType::SignificantDigits);
// b. Let mnsd be ? DefaultNumberOption(mnsd, 1, 21, 1).
auto min_digits = default_number_option(global_object, min_significant_digits, 1, 21, 1);
if (vm.exception())
return;
// c. Let mxsd be ? DefaultNumberOption(mxsd, mnsd, 21, 21).
auto max_digits = default_number_option(global_object, max_significant_digits, *min_digits, 21, 21);
if (vm.exception())
return;
// d. Set intlObj.[[MinimumSignificantDigits]] to mnsd.
intl_object.set_min_significant_digits(*min_digits);
// e. Set intlObj.[[MaximumSignificantDigits]] to mxsd.
intl_object.set_max_significant_digits(*max_digits);
}
// 12. Else if mnfd is not undefined or mxfd is not undefined, then
else if (!min_fraction_digits.is_undefined() || !max_fraction_digits.is_undefined()) {
// a. Set intlObj.[[RoundingType]] to fractionDigits.
intl_object.set_rounding_type(NumberFormat::RoundingType::FractionDigits);
// b. Let mnfd be ? DefaultNumberOption(mnfd, 0, 20, undefined).
auto min_digits = default_number_option(global_object, min_fraction_digits, 0, 20, {});
if (vm.exception())
return;
// c. Let mxfd be ? DefaultNumberOption(mxfd, 0, 20, undefined).
auto max_digits = default_number_option(global_object, max_fraction_digits, 0, 20, {});
if (vm.exception())
return;
// d. If mnfd is undefined, set mnfd to min(mnfdDefault, mxfd).
if (!min_digits.has_value()) {
min_digits = min(default_min_fraction_digits, *max_digits);
}
// e. Else if mxfd is undefined, set mxfd to max(mxfdDefault, mnfd).
else if (!max_digits.has_value()) {
max_digits = max(default_max_fraction_digits, *min_digits);
}
// f. Else if mnfd is greater than mxfd, throw a RangeError exception.
else if (*min_digits > *max_digits) {
vm.throw_exception<RangeError>(global_object, ErrorType::IntlMinimumExceedsMaximum, *min_digits, *max_digits);
return;
}
// g. Set intlObj.[[MinimumFractionDigits]] to mnfd.
intl_object.set_min_fraction_digits(*min_digits);
// h. Set intlObj.[[MaximumFractionDigits]] to mxfd.
intl_object.set_max_fraction_digits(*max_digits);
}
// 13. Else if notation is "compact", then
else if (notation == NumberFormat::Notation::Compact) {
// a. Set intlObj.[[RoundingType]] to compactRounding.
intl_object.set_rounding_type(NumberFormat::RoundingType::CompactRounding);
}
// 14. Else,
else {
// a. Set intlObj.[[RoundingType]] to fractionDigits.
intl_object.set_rounding_type(NumberFormat::RoundingType::FractionDigits);
// b. Set intlObj.[[MinimumFractionDigits]] to mnfdDefault.
intl_object.set_min_fraction_digits(default_min_fraction_digits);
// c. Set intlObj.[[MaximumFractionDigits]] to mxfdDefault.
intl_object.set_max_fraction_digits(default_max_fraction_digits);
}
}
// 15.1.2 InitializeNumberFormat ( numberFormat, locales, options ), https://tc39.es/ecma402/#sec-initializenumberformat
NumberFormat* initialize_number_format(GlobalObject& global_object, NumberFormat& number_format, Value locales_value, Value options_value)
{
auto& vm = global_object.vm();
// 1. Let requestedLocales be ? CanonicalizeLocaleList(locales).
auto requested_locales = canonicalize_locale_list(global_object, locales_value);
if (vm.exception())
return {};
// 2. Set options to ? CoerceOptionsToObject(options).
auto* options = coerce_options_to_object(global_object, options_value);
if (vm.exception())
return {};
// 3. Let opt be a new Record.
LocaleOptions opt {};
// 4. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
auto matcher = get_option(global_object, *options, vm.names.localeMatcher, Value::Type::String, { "lookup"sv, "best fit"sv }, "best fit"sv);
if (vm.exception())
return {};
// 5. Set opt.[[localeMatcher]] to matcher.
opt.locale_matcher = matcher;
// 6. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined).
auto numbering_system = get_option(global_object, *options, vm.names.numberingSystem, Value::Type::String, {}, Empty {});
if (vm.exception())
return {};
// 7. If numberingSystem is not undefined, then
if (!numbering_system.is_undefined()) {
// a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
if (!Unicode::is_type_identifier(numbering_system.as_string().string())) {
vm.throw_exception<RangeError>(global_object, ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv);
return {};
}
// 8. Set opt.[[nu]] to numberingSystem.
opt.nu = numbering_system.as_string().string();
}
// 9. Let localeData be %NumberFormat%.[[LocaleData]].
// 10. Let r be ResolveLocale(%NumberFormat%.[[AvailableLocales]], requestedLocales, opt, %NumberFormat%.[[RelevantExtensionKeys]], localeData).
auto result = resolve_locale(requested_locales, opt, NumberFormat::relevant_extension_keys());
// 11. Set numberFormat.[[Locale]] to r.[[locale]].
number_format.set_locale(move(result.locale));
// 12. Set numberFormat.[[DataLocale]] to r.[[dataLocale]].
number_format.set_data_locale(move(result.data_locale));
// 13. Set numberFormat.[[NumberingSystem]] to r.[[nu]].
number_format.set_numbering_system(result.nu.release_value());
// 14. Perform ? SetNumberFormatUnitOptions(numberFormat, options).
set_number_format_unit_options(global_object, number_format, *options);
if (vm.exception())
return {};
// 15. Let style be numberFormat.[[Style]].
auto style = number_format.style();
int default_min_fraction_digits = 0;
int default_max_fraction_digits = 0;
// 16. If style is "currency", then
if (style == NumberFormat::Style::Currency) {
// a. Let currency be numberFormat.[[Currency]].
auto const& currency = number_format.currency();
// b. Let cDigits be CurrencyDigits(currency).
int digits = currency_digits(currency);
// c. Let mnfdDefault be cDigits.
default_min_fraction_digits = digits;
// d. Let mxfdDefault be cDigits.
default_max_fraction_digits = digits;
}
// 17. Else,
else {
// a. Let mnfdDefault be 0.
default_min_fraction_digits = 0;
// b. If style is "percent", then
// i. Let mxfdDefault be 0.
// c. Else,
// i. Let mxfdDefault be 3.
default_max_fraction_digits = style == NumberFormat::Style::Percent ? 0 : 3;
}
// 18. Let notation be ? GetOption(options, "notation", "string", « "standard", "scientific", "engineering", "compact" », "standard").
auto notation = get_option(global_object, *options, vm.names.notation, Value::Type::String, { "standard"sv, "scientific"sv, "engineering"sv, "compact"sv }, "standard"sv);
if (vm.exception())
return {};
// 19. Set numberFormat.[[Notation]] to notation.
number_format.set_notation(notation.as_string().string());
// 20. Perform ? SetNumberFormatDigitOptions(numberFormat, options, mnfdDefault, mxfdDefault, notation).
set_number_format_digit_options(global_object, number_format, *options, default_min_fraction_digits, default_max_fraction_digits, number_format.notation());
if (vm.exception())
return {};
// 21. Let compactDisplay be ? GetOption(options, "compactDisplay", "string", « "short", "long" », "short").
auto compact_display = get_option(global_object, *options, vm.names.compactDisplay, Value::Type::String, { "short"sv, "long"sv }, "short"sv);
if (vm.exception())
return {};
// 22. If notation is "compact", then
if (number_format.notation() == NumberFormat::Notation::Compact) {
// a. Set numberFormat.[[CompactDisplay]] to compactDisplay.
number_format.set_compact_display(compact_display.as_string().string());
}
// 23. Let useGrouping be ? GetOption(options, "useGrouping", "boolean", undefined, true).
auto use_grouping = get_option(global_object, *options, vm.names.useGrouping, Value::Type::Boolean, {}, true);
if (vm.exception())
return {};
// 24. Set numberFormat.[[UseGrouping]] to useGrouping.
number_format.set_use_grouping(use_grouping.as_bool());
// 25. Let signDisplay be ? GetOption(options, "signDisplay", "string", « "auto", "never", "always", "exceptZero" », "auto").
auto sign_display = get_option(global_object, *options, vm.names.signDisplay, Value::Type::String, { "auto"sv, "never"sv, "always"sv, "exceptZero"sv }, "auto"sv);
if (vm.exception())
return {};
// 26. Set numberFormat.[[SignDisplay]] to signDisplay.
number_format.set_sign_display(sign_display.as_string().string());
// 27. Return numberFormat.
return &number_format;
}
// 15.1.3 CurrencyDigits ( currency ), https://tc39.es/ecma402/#sec-currencydigits
int currency_digits(StringView currency)
{
// 1. If the ISO 4217 currency and funds code list contains currency as an alphabetic code, return the minor
// unit value corresponding to the currency from the list; otherwise, return 2.
if (auto currency_code = Unicode::get_currency_code(currency); currency_code.has_value())
return currency_code->minor_unit.value_or(2);
return 2;
}
// 15.1.13 SetNumberFormatUnitOptions ( intlObj, options ), https://tc39.es/ecma402/#sec-setnumberformatunitoptions
void set_number_format_unit_options(GlobalObject& global_object, NumberFormat& intl_object, Object const& options)
{
auto& vm = global_object.vm();
// 1. Assert: Type(intlObj) is Object.
// 2. Assert: Type(options) is Object.
// 3. Let style be ? GetOption(options, "style", "string", « "decimal", "percent", "currency", "unit" », "decimal").
auto style = get_option(global_object, options, vm.names.style, Value::Type::String, { "decimal"sv, "percent"sv, "currency"sv, "unit"sv }, "decimal"sv);
if (vm.exception())
return;
// 4. Set intlObj.[[Style]] to style.
intl_object.set_style(style.as_string().string());
// 5. Let currency be ? GetOption(options, "currency", "string", undefined, undefined).
auto currency = get_option(global_object, options, vm.names.currency, Value::Type::String, {}, Empty {});
if (vm.exception())
return;
// 6. If currency is undefined, then
if (currency.is_undefined()) {
// a. If style is "currency", throw a TypeError exception.
if (intl_object.style() == NumberFormat::Style::Currency) {
vm.throw_exception<TypeError>(global_object, ErrorType::IntlOptionUndefined, "currency"sv, "style"sv, style);
return;
}
}
// 7. Else,
// a. If the result of IsWellFormedCurrencyCode(currency) is false, throw a RangeError exception.
else if (!is_well_formed_currency_code(currency.as_string().string())) {
vm.throw_exception<RangeError>(global_object, ErrorType::OptionIsNotValidValue, currency, "currency"sv);
return;
}
// 8. Let currencyDisplay be ? GetOption(options, "currencyDisplay", "string", « "code", "symbol", "narrowSymbol", "name" », "symbol").
auto currency_display = get_option(global_object, options, vm.names.currencyDisplay, Value::Type::String, { "code"sv, "symbol"sv, "narrowSymbol"sv, "name"sv }, "symbol"sv);
if (vm.exception())
return;
// 9. Let currencySign be ? GetOption(options, "currencySign", "string", « "standard", "accounting" », "standard").
auto currency_sign = get_option(global_object, options, vm.names.currencySign, Value::Type::String, { "standard"sv, "accounting"sv }, "standard"sv);
if (vm.exception())
return;
// 10. Let unit be ? GetOption(options, "unit", "string", undefined, undefined).
auto unit = get_option(global_object, options, vm.names.unit, Value::Type::String, {}, Empty {});
if (vm.exception())
return;
// 11. If unit is undefined, then
if (unit.is_undefined()) {
// a. If style is "unit", throw a TypeError exception.
if (intl_object.style() == NumberFormat::Style::Unit) {
vm.throw_exception<TypeError>(global_object, ErrorType::IntlOptionUndefined, "unit"sv, "style"sv, style);
return;
}
}
// 12. Else,
// a. If the result of IsWellFormedUnitIdentifier(unit) is false, throw a RangeError exception.
else if (!is_well_formed_unit_identifier(unit.as_string().string())) {
vm.throw_exception<RangeError>(global_object, ErrorType::OptionIsNotValidValue, unit, "unit"sv);
return;
}
// 13. Let unitDisplay be ? GetOption(options, "unitDisplay", "string", « "short", "narrow", "long" », "short").
auto unit_display = get_option(global_object, options, vm.names.unitDisplay, Value::Type::String, { "short"sv, "narrow"sv, "long"sv }, "short"sv);
if (vm.exception())
return;
// 14. If style is "currency", then
if (intl_object.style() == NumberFormat::Style::Currency) {
// a. Let currency be the result of converting currency to upper case as specified in 6.1.
// b. Set intlObj.[[Currency]] to currency.
intl_object.set_currency(currency.as_string().string().to_uppercase());
// c. Set intlObj.[[CurrencyDisplay]] to currencyDisplay.
intl_object.set_currency_display(currency_display.as_string().string());
// d. Set intlObj.[[CurrencySign]] to currencySign.
intl_object.set_currency_sign(currency_sign.as_string().string());
}
// 15. If style is "unit", then
if (intl_object.style() == NumberFormat::Style::Unit) {
// a. Set intlObj.[[Unit]] to unit.
intl_object.set_unit(unit.as_string().string());
// b. Set intlObj.[[UnitDisplay]] to unitDisplay.
intl_object.set_unit_display(unit_display.as_string().string());
}
}
}
|