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 /** | 5 /** |
6 * DateFormat is for formatting and parsing dates in a locale-sensitive | 6 * DateFormat is for formatting and parsing dates in a locale-sensitive |
7 * manner. | 7 * manner. |
8 * It allows the user to choose from a set of standard date time formats as well | 8 * It allows the user to choose from a set of standard date time formats as well |
9 * as specify a customized pattern under certain locales. Date elements that | 9 * as specify a customized pattern under certain locales. Date elements that |
10 * vary across locales include month name, week name, field order, etc. | 10 * vary across locales include month name, week name, field order, etc. |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 (pattern, parent) => new _DateFormatLiteralField(pattern, parent)]; | 526 (pattern, parent) => new _DateFormatLiteralField(pattern, parent)]; |
527 | 527 |
528 /** Parse the template pattern and return a list of field objects.*/ | 528 /** Parse the template pattern and return a list of field objects.*/ |
529 List parsePattern(String pattern) { | 529 List parsePattern(String pattern) { |
530 if (pattern == null) return null; | 530 if (pattern == null) return null; |
531 return _reverse(_parsePatternHelper(pattern)); | 531 return _reverse(_parsePatternHelper(pattern)); |
532 } | 532 } |
533 | 533 |
534 /** Recursive helper for parsing the template pattern. */ | 534 /** Recursive helper for parsing the template pattern. */ |
535 List _parsePatternHelper(String pattern) { | 535 List _parsePatternHelper(String pattern) { |
536 if (pattern.isEmpty()) return []; | 536 if (pattern.isEmpty) return []; |
537 | 537 |
538 var matched = _match(pattern); | 538 var matched = _match(pattern); |
539 if (matched == null) return []; | 539 if (matched == null) return []; |
540 | 540 |
541 var parsed = _parsePatternHelper( | 541 var parsed = _parsePatternHelper( |
542 pattern.substring(matched.fullPattern().length)); | 542 pattern.substring(matched.fullPattern().length)); |
543 parsed.add(matched); | 543 parsed.add(matched); |
544 return parsed; | 544 return parsed; |
545 } | 545 } |
546 | 546 |
(...skipping 12 matching lines...) Expand all Loading... |
559 List _reverse(List list) { | 559 List _reverse(List list) { |
560 // TODO(alanknight): Use standardized list reverse when implemented. | 560 // TODO(alanknight): Use standardized list reverse when implemented. |
561 // See Issue 2804. | 561 // See Issue 2804. |
562 var result = new List(); | 562 var result = new List(); |
563 for (var i = list.length-1; i >= 0; i--) { | 563 for (var i = list.length-1; i >= 0; i--) { |
564 result.addLast(list[i]); | 564 result.addLast(list[i]); |
565 } | 565 } |
566 return result; | 566 return result; |
567 } | 567 } |
568 } | 568 } |
OLD | NEW |