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

Side by Side Diff: pkg/intl/lib/date_format.dart

Issue 11091012: Clean up TODOs and comments in Intl (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | pkg/intl/lib/intl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 * 177 *
178 * If [locale] does not exist in our set of supported locales then an 178 * If [locale] does not exist in our set of supported locales then an
179 * [ArgumentError] is thrown. 179 * [ArgumentError] is thrown.
180 */ 180 */
181 DateFormat([String newPattern, String locale]) { 181 DateFormat([String newPattern, String locale]) {
182 // TODO(alanknight): It should be possible to specify multiple skeletons eg 182 // TODO(alanknight): It should be possible to specify multiple skeletons eg
183 // date, time, timezone all separately. Adding many or named parameters to 183 // date, time, timezone all separately. Adding many or named parameters to
184 // the constructor seems awkward, especially with the possibility of 184 // the constructor seems awkward, especially with the possibility of
185 // confusion with the locale. A "fluent" interface with cascading on an 185 // confusion with the locale. A "fluent" interface with cascading on an
186 // instance might work better? A list of patterns is also possible. 186 // instance might work better? A list of patterns is also possible.
187 // TODO(alanknight): There will need to be at least setup type async
188 // operations to avoid the need to bring along every locale in every program
189 _locale = Intl.verifiedLocale(locale); 187 _locale = Intl.verifiedLocale(locale);
190 addPattern(newPattern); 188 addPattern(newPattern);
191 } 189 }
192 190
193 /** 191 /**
194 * Return a string representing [date] formatted according to our locale 192 * Return a string representing [date] formatted according to our locale
195 * and internal format. 193 * and internal format.
196 */ 194 */
197 String format(Date date) { 195 String format(Date date) {
198 // TODO(efortuna): read optional TimeZone argument (or similar)? 196 // TODO(efortuna): read optional TimeZone argument (or similar)?
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 513
516 /** 514 /**
517 * Return true if the locale exists, or if it is null. The null case 515 * Return true if the locale exists, or if it is null. The null case
518 * is interpreted to mean that we use the default locale. 516 * is interpreted to mean that we use the default locale.
519 */ 517 */
520 static bool localeExists(localeName) { 518 static bool localeExists(localeName) {
521 if (localeName == null) return false; 519 if (localeName == null) return false;
522 return dateTimeSymbols.containsKey(localeName); 520 return dateTimeSymbols.containsKey(localeName);
523 } 521 }
524 522
525 // TODO(alanknight): This can be a variable once that's permitted.
526 static List get _fieldConstructors => [ 523 static List get _fieldConstructors => [
527 (pattern, parent) => new _DateFormatQuotedField(pattern, parent), 524 (pattern, parent) => new _DateFormatQuotedField(pattern, parent),
528 (pattern, parent) => new _DateFormatPatternField(pattern, parent), 525 (pattern, parent) => new _DateFormatPatternField(pattern, parent),
529 (pattern, parent) => new _DateFormatLiteralField(pattern, parent)]; 526 (pattern, parent) => new _DateFormatLiteralField(pattern, parent)];
530 527
531 /** Parse the template pattern and return a list of field objects.*/ 528 /** Parse the template pattern and return a list of field objects.*/
532 List parsePattern(String pattern) { 529 List parsePattern(String pattern) {
533 if (pattern == null) return null; 530 if (pattern == null) return null;
534 return _reverse(_parsePatternHelper(pattern)); 531 return _reverse(_parsePatternHelper(pattern));
535 } 532 }
(...skipping 26 matching lines...) Expand all
562 List _reverse(List list) { 559 List _reverse(List list) {
563 // TODO(alanknight): Use standardized list reverse when implemented. 560 // TODO(alanknight): Use standardized list reverse when implemented.
564 // See Issue 2804. 561 // See Issue 2804.
565 var result = new List(); 562 var result = new List();
566 for (var i = list.length-1; i >= 0; i--) { 563 for (var i = list.length-1; i >= 0; i--) {
567 result.addLast(list[i]); 564 result.addLast(list[i]);
568 } 565 }
569 return result; 566 return result;
570 } 567 }
571 } 568 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/lib/intl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698