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

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

Issue 10917069: Async initialization for DateFormat (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 * more digit string will be interpreted as its face value. 150 * more digit string will be interpreted as its face value.
151 * 151 *
152 * If the year pattern does not have exactly two 'y' characters, the year is 152 * If the year pattern does not have exactly two 'y' characters, the year is
153 * interpreted literally, regardless of the number of digits. So using the 153 * interpreted literally, regardless of the number of digits. So using the
154 * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D. 154 * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
155 */ 155 */
156 156
157 #library('date_format'); 157 #library('date_format');
158 158
159 #import('dart:math'); 159 #import('dart:math');
160
161 #import('intl.dart'); 160 #import('intl.dart');
162 #import('date_time_patterns.dart');
163 #import('date_symbols.dart'); 161 #import('date_symbols.dart');
164 #import('date_symbol_data.dart'); 162 #import('lib/intl_helpers.dart');
163 #import('lib/date_format_internal.dart');
165 164
166 #source('lib/date_format_field.dart'); 165 #source('lib/date_format_field.dart');
167 #source('lib/date_format_helpers.dart'); 166 #source('lib/date_format_helpers.dart');
168 167
169 class DateFormat { 168 class DateFormat {
170 169
171 /** 170 /**
172 * If [newPattern] matches one of the skeleton forms, it is looked up 171 * If [newPattern] matches one of the skeleton forms, it is looked up
173 * in [locale] or in the default if none is specified, and the corresponding 172 * in [locale] or in the default if none is specified, and the corresponding
174 * full format string is used. If [newPattern] does not match one 173 * full format string is used. If [newPattern] does not match one
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Date parseUTC(String inputString) { 247 Date parseUTC(String inputString) {
249 return parse(inputString, true); 248 return parse(inputString, true);
250 } 249 }
251 250
252 /** 251 /**
253 * Return the locale code in which we operate, e.g. 'en_US' or 'pt'. 252 * Return the locale code in which we operate, e.g. 'en_US' or 'pt'.
254 */ 253 */
255 String get locale() => _locale; 254 String get locale() => _locale;
256 255
257 /** 256 /**
257 * Returns a list of all locales for which we have date formatting
258 * information.
259 */
260 static List<String> allLocalesWithSymbols() => dateTimeSymbols.getKeys();
261
262 /**
258 * Constructors for a set of predefined formats for which 263 * Constructors for a set of predefined formats for which
259 * internationalized forms are known. These can be specified 264 * internationalized forms are known. These can be specified
260 * either as ICU constants, or as skeletons. 265 * either as ICU constants, or as skeletons.
261 */ 266 */
262 DateFormat.DAY([locale]) : this(DAY, locale); 267 DateFormat.DAY([locale]) : this(DAY, locale);
263 DateFormat.ABBR_WEEKDAY([locale]) : this(ABBR_WEEKDAY, locale); 268 DateFormat.ABBR_WEEKDAY([locale]) : this(ABBR_WEEKDAY, locale);
264 DateFormat.WEEKDAY([locale]) : this(WEEKDAY, locale); 269 DateFormat.WEEKDAY([locale]) : this(WEEKDAY, locale);
265 DateFormat.ABBR_STANDALONE_MONTH([locale]) : 270 DateFormat.ABBR_STANDALONE_MONTH([locale]) :
266 this(ABBR_STANDALONE_MONTH, locale); 271 this(ABBR_STANDALONE_MONTH, locale);
267 DateFormat.STANDALONE_MONTH([locale]) : this(STANDALONE_MONTH, locale); 272 DateFormat.STANDALONE_MONTH([locale]) : this(STANDALONE_MONTH, locale);
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 List _reverse(List list) { 597 List _reverse(List list) {
593 // TODO(alanknight): Use standardized list reverse when implemented. 598 // TODO(alanknight): Use standardized list reverse when implemented.
594 // See Issue 2804. 599 // See Issue 2804.
595 var result = new List(); 600 var result = new List();
596 for (var i = list.length-1; i >= 0; i--) { 601 for (var i = list.length-1; i >= 0; i--) {
597 result.addLast(list[i]); 602 result.addLast(list[i]);
598 } 603 }
599 return result; 604 return result;
600 } 605 }
601 } 606 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698