OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @param {string} toTest The string to be tested. | 6 * @param {string} toTest The string to be tested. |
7 * @return {boolean} True if |toTest| contains only digits. Leading and trailing | 7 * @return {boolean} True if |toTest| contains only digits. Leading and trailing |
8 * whitespace is allowed. | 8 * whitespace is allowed. |
9 */ | 9 */ |
10 function isInteger(toTest) { | 10 function isInteger(toTest) { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 240 } |
241 | 241 |
242 /** | 242 /** |
243 * Converts |value| from points to millimeters. | 243 * Converts |value| from points to millimeters. |
244 * @param {number} value The number in points. | 244 * @param {number} value The number in points. |
245 * @return {number} |value| in millimeters. | 245 * @return {number} |value| in millimeters. |
246 */ | 246 */ |
247 function convertPointsToMillimeters(value) { | 247 function convertPointsToMillimeters(value) { |
248 return value / POINTS_PER_MILLIMETER; | 248 return value / POINTS_PER_MILLIMETER; |
249 } | 249 } |
| 250 |
| 251 /** |
| 252 * Parses |numberFormat| and extracts the symbols used for the thousands point |
| 253 * and decimal point. |
| 254 * @param {string} numberFormat The formatted version of the number 12345678. |
| 255 * @return {!array.<string>} The extracted symbols in the order |
| 256 * [thousandsSymbol, decimalSymbol]]. For example |
| 257 * parseNumberFormat("123,456.78") returns [",", "."]. |
| 258 */ |
| 259 function parseNumberFormat(numberFormat) { |
| 260 if (!numberFormat) |
| 261 numberFormat = ''; |
| 262 var regex = /^(\d+)(\W{0,1})(\d+)(\W{0,1})(\d+)$/; |
| 263 var matches = numberFormat.match(regex) || ['','',',','','.']; |
| 264 return [matches[2], matches[4]]; |
| 265 } |
OLD | NEW |