| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of intl; | 5 part of intl; |
| 6 | 6 |
| 7 // TODO(efortuna): Customized pattern system -- suggested by i18n needs | 7 // TODO(efortuna): Customized pattern system -- suggested by i18n needs |
| 8 // feedback on appropriateness. | 8 // feedback on appropriateness. |
| 9 /** | 9 /** |
| 10 * DateFormat is for formatting and parsing dates in a locale-sensitive | 10 * DateFormat is for formatting and parsing dates in a locale-sensitive |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 * Formats a string indicating how long ago (negative [duration]) or how far | 245 * Formats a string indicating how long ago (negative [duration]) or how far |
| 246 * in the future (positive [duration]) some time is with respect to a | 246 * in the future (positive [duration]) some time is with respect to a |
| 247 * reference [date]. | 247 * reference [date]. |
| 248 */ | 248 */ |
| 249 String formatDurationFrom(Duration duration, DateTime date) { | 249 String formatDurationFrom(Duration duration, DateTime date) { |
| 250 return ''; | 250 return ''; |
| 251 } | 251 } |
| 252 | 252 |
| 253 /** | 253 /** |
| 254 * Given user input, attempt to parse the [inputString] into the anticipated | 254 * Given user input, attempt to parse the [inputString] into the anticipated |
| 255 * format, treating it as being in the local timezone. | 255 * format, treating it as being in the local timezone. If [inputString] does |
| 256 * not match our format, throws a [FormatException]. |
| 256 */ | 257 */ |
| 257 DateTime parse(String inputString, [utc = false]) { | 258 DateTime parse(String inputString, [utc = false]) { |
| 258 // TODO(alanknight): The Closure code refers to special parsing of numeric | 259 // TODO(alanknight): The Closure code refers to special parsing of numeric |
| 259 // values with no delimiters, which we currently don't do. Should we? | 260 // values with no delimiters, which we currently don't do. Should we? |
| 260 var dateFields = new _DateBuilder(); | 261 var dateFields = new _DateBuilder(); |
| 261 if (utc) dateFields.utc=true; | 262 if (utc) dateFields.utc=true; |
| 262 var stream = new _Stream(inputString); | 263 var stream = new _Stream(inputString); |
| 263 _formatFields.forEach( | 264 _formatFields.forEach( |
| 264 (each) => each.parse(stream, dateFields)); | 265 (each) => each.parse(stream, dateFields)); |
| 265 return dateFields.asDate(); | 266 return dateFields.asDate(); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 _DateFormatField _match(String pattern) { | 591 _DateFormatField _match(String pattern) { |
| 591 for (var i = 0; i < _matchers.length; i++) { | 592 for (var i = 0; i < _matchers.length; i++) { |
| 592 var regex = _matchers[i]; | 593 var regex = _matchers[i]; |
| 593 var match = regex.firstMatch(pattern); | 594 var match = regex.firstMatch(pattern); |
| 594 if (match != null) { | 595 if (match != null) { |
| 595 return _fieldConstructors[i](match.group(0), this); | 596 return _fieldConstructors[i](match.group(0), this); |
| 596 } | 597 } |
| 597 } | 598 } |
| 598 } | 599 } |
| 599 } | 600 } |
| OLD | NEW |