Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: pkg/intl/lib/src/intl/number_format.dart

Issue 607153002: Support percent/permille formats with positive and negative variations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update CHANGELOG.md and bump package version number Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/intl/CHANGELOG.md ('k') | pkg/intl/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/src/intl/number_format.dart
diff --git a/pkg/intl/lib/src/intl/number_format.dart b/pkg/intl/lib/src/intl/number_format.dart
index e43b471c53b46e76291d5a68bd254f17b6505fc2..377db7dea10689800e8814470ed61959b2491ced 100644
--- a/pkg/intl/lib/src/intl/number_format.dart
+++ b/pkg/intl/lib/src/intl/number_format.dart
@@ -495,11 +495,11 @@ class _NumberParser {
symbols.EXP_SYMBOL: () => 'E',
symbols.GROUP_SEP: handleSpace,
symbols.PERCENT: () {
- scale = 100;
+ scale = _NumberFormatParser._PERCENT_SCALE;
return '';
},
symbols.PERMILL: () {
- scale = 1000;
+ scale = _NumberFormatParser._PER_MILLE_SCALE;
return '';
},
' ' : handleSpace,
@@ -676,7 +676,9 @@ class _NumberFormatParser {
static const _PATTERN_DECIMAL_SEPARATOR = '.';
static const _PATTERN_CURRENCY_SIGN = '\u00A4';
static const _PATTERN_PER_MILLE = '\u2030';
+ static const _PER_MILLE_SCALE = 1000;
static const _PATTERN_PERCENT = '%';
+ static const _PERCENT_SCALE = 100;
static const _PATTERN_EXPONENT = 'E';
static const _PATTERN_PLUS = '+';
@@ -778,17 +780,18 @@ class _NumberFormatParser {
affix.write(currencyName);
break;
case _PATTERN_PERCENT:
- if (format._multiplier != 1) {
+ if (format._multiplier != 1 && format._multiplier != _PERCENT_SCALE) {
throw new FormatException('Too many percent/permill');
}
- format._multiplier = 100;
+ format._multiplier = _PERCENT_SCALE;
affix.write(symbols.PERCENT);
break;
case _PATTERN_PER_MILLE:
- if (format._multiplier != 1) {
+ if (format._multiplier != 1 &&
+ format._multiplier != _PER_MILLE_SCALE) {
throw new FormatException('Too many percent/permill');
}
- format._multiplier = 1000;
+ format._multiplier = _PER_MILLE_SCALE;
affix.write(symbols.PERMILL);
break;
default:
« no previous file with comments | « pkg/intl/CHANGELOG.md ('k') | pkg/intl/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698