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

Side by Side Diff: third_party/pkg/angular/lib/formatter/currency.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 part of angular.formatter_internal;
2
3 /**
4 * Formats a number as a currency (ie $1,234.56). When no currency symbol is
5 * provided, '$' used.
6 *
7 *
8 * Usage:
9 *
10 * {{ numeric_expression | currency[:symbol[:leading]] }}
11 *
12 */
13 @Formatter(name:'currency')
14 class Currency implements Function {
15
16 var _nfs = new Map<String, NumberFormat>();
17
18 /**
19 * [value]: the value to format
20 *
21 * [symbol]: Symbol to use.
22 *
23 * [leading]: Symbol should be placed in front of the number
24 */
25 call(value, [symbol = r'$', leading = true]) {
26 if (value is String) value = double.parse(value);
27 if (value is! num) return value;
28 if (value.isNaN) return '';
29 var verifiedLocale = Intl.verifiedLocale(Intl.getCurrentLocale(), NumberForm at.localeExists);
30 var nf = _nfs[verifiedLocale];
31 if (nf == null) {
32 nf = new NumberFormat();
33 nf.minimumFractionDigits = 2;
34 nf.maximumFractionDigits = 2;
35 _nfs[verifiedLocale] = nf;
36 }
37 var neg = value < 0;
38 if (neg) value = -value;
39 var before = neg ? '(' : '';
40 var after = neg ? ')' : '';
41 return leading ?
42 '$before$symbol${nf.format(value)}$after' :
43 '$before${nf.format(value)}$symbol$after';
44 }
45 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/formatter/arrayify.dart ('k') | third_party/pkg/angular/lib/formatter/date.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698