OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. All rights reserved. | 2 * Copyright 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style | 4 * Use of this source code is governed by a BSD-style |
5 * license that can be found in the LICENSE file or at | 5 * license that can be found in the LICENSE file or at |
6 * https://developers.google.com/open-source/licenses/bsd | 6 * https://developers.google.com/open-source/licenses/bsd |
7 */ | 7 */ |
8 part of charted.locale.format; | 8 part of charted.locale.format; |
9 | 9 |
10 /** | 10 /** |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 var i = value.lastIndexOf('.'), | 179 var i = value.lastIndexOf('.'), |
180 before = i < 0 ? value : value.substring(0, i), | 180 before = i < 0 ? value : value.substring(0, i), |
181 after = i < 0 ? '' : localeDecimal + value.substring(i + 1); | 181 after = i < 0 ? '' : localeDecimal + value.substring(i + 1); |
182 | 182 |
183 // If the fill character is not '0', grouping is applied before | 183 // If the fill character is not '0', grouping is applied before |
184 //padding. | 184 //padding. |
185 if (zfill == null && comma) { | 185 if (zfill == null && comma) { |
186 before = formatGroup(before); | 186 before = formatGroup(before); |
187 } | 187 } |
188 | 188 |
189 var length = prefix.length + | 189 int length = prefix.length + |
190 before.length + | 190 before.length + |
191 after.length + | 191 after.length + |
192 (zcomma ? 0 : negative.length), | 192 (zcomma ? 0 : negative.length); |
193 padding = length < width | 193 var padding = length < width |
194 ? new List.filled((length = width - length + 1), '').join(fill) | 194 ? new List.filled((length = width - length + 1), '').join(fill) |
195 : ''; | 195 : ''; |
196 | 196 |
197 // If the fill character is '0', grouping is applied after padding. | 197 // If the fill character is '0', grouping is applied after padding. |
198 if (zcomma) { | 198 if (zcomma) { |
199 before = formatGroup(padding + before); | 199 before = formatGroup(padding + before); |
200 } | 200 } |
201 | 201 |
202 // Apply prefix. | 202 // Apply prefix. |
203 negative += prefix; | 203 negative += prefix; |
204 | 204 |
205 // Rejoin integer and decimal parts. | 205 // Rejoin integer and decimal parts. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 case 'e': | 239 case 'e': |
240 return (num x, [int p = 0]) => x.toStringAsExponential(p); | 240 return (num x, [int p = 0]) => x.toStringAsExponential(p); |
241 case 'f': | 241 case 'f': |
242 return (num x, [int p = 0]) => x.toStringAsFixed(p); | 242 return (num x, [int p = 0]) => x.toStringAsFixed(p); |
243 case 'r': | 243 case 'r': |
244 default: | 244 default: |
245 return (num x, [int p = 0]) => x.toString(); | 245 return (num x, [int p = 0]) => x.toString(); |
246 } | 246 } |
247 } | 247 } |
248 } | 248 } |
OLD | NEW |