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

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

Issue 10916128: Clean up Intl for language changes (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
« no previous file with comments | « pkg/intl/intl.dart ('k') | pkg/intl/number_format.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 * This is a private class internal to DateFormat which is used for formatting 6 * This is a private class internal to DateFormat which is used for formatting
7 * particular fields in a template. e.g. if the format is hh:mm:ss then the 7 * particular fields in a template. e.g. if the format is hh:mm:ss then the
8 * fields would be "hh", ":", "mm", ":", and "ss". Each type of field knows 8 * fields would be "hh", ":", "mm", ":", and "ss". Each type of field knows
9 * how to format that portion of a date. 9 * how to format that portion of a date.
10 */ 10 */
11 class _DateFormatField { 11 class _DateFormatField {
12 /** The format string that defines us, e.g. "hh" */ 12 /** The format string that defines us, e.g. "hh" */
13 String pattern; 13 String pattern;
14 14
15 /** The DateFormat that we are part of.*/ 15 /** The DateFormat that we are part of.*/
16 DateFormat parent; 16 DateFormat parent;
17 17
18 _DateFormatField(this.pattern, this.parent); 18 _DateFormatField(this.pattern, this.parent);
19 19
20 /** 20 /**
21 * Return the width of [pattern]. Different widths represent different 21 * Return the width of [pattern]. Different widths represent different
22 * formatting options. See the comment for DateFormat for details. 22 * formatting options. See the comment for DateFormat for details.
23 */ 23 */
24 int get width() => pattern.length; 24 int get width => pattern.length;
25 25
26 String fullPattern() => pattern; 26 String fullPattern() => pattern;
27 27
28 String toString() => pattern; 28 String toString() => pattern;
29 29
30 /** Format date according to our specification and return the result. */ 30 /** Format date according to our specification and return the result. */
31 String format(Date date) { 31 String format(Date date) {
32 // Default implementation in the superclass, works for both types of 32 // Default implementation in the superclass, works for both types of
33 // literal patterns, and is overridden by _DateFormatPatternField. 33 // literal patterns, and is overridden by _DateFormatPatternField.
34 return pattern; 34 return pattern;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 case 's': return formatSeconds(date); 168 case 's': return formatSeconds(date);
169 case 'v': return formatTimeZoneId(date); 169 case 'v': return formatTimeZoneId(date);
170 case 'y': return formatYear(date); 170 case 'y': return formatYear(date);
171 case 'z': return formatTimeZone(date); 171 case 'z': return formatTimeZone(date);
172 case 'Z': return formatTimeZoneRFC(date); 172 case 'Z': return formatTimeZoneRFC(date);
173 default: return ''; 173 default: return '';
174 } 174 }
175 } 175 }
176 176
177 /** Return the symbols for our current locale. */ 177 /** Return the symbols for our current locale. */
178 DateSymbols get symbols() => dateTimeSymbols[parent.locale]; 178 DateSymbols get symbols => dateTimeSymbols[parent.locale];
179 179
180 formatEra(Date date) { 180 formatEra(Date date) {
181 var era = date.year > 0 ? 1 : 0; 181 var era = date.year > 0 ? 1 : 0;
182 return width >= 4 ? symbols.ERANAMES[era] : 182 return width >= 4 ? symbols.ERANAMES[era] :
183 symbols.ERAS[era]; 183 symbols.ERAS[era];
184 } 184 }
185 185
186 formatYear(Date date) { 186 formatYear(Date date) {
187 // TODO(alanknight): Proper handling of years <= 0 187 // TODO(alanknight): Proper handling of years <= 0
188 var year = date.year; 188 var year = date.year;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 var basicString = toBePrinted.toString(); 394 var basicString = toBePrinted.toString();
395 if (basicString.length >= width) return basicString; 395 if (basicString.length >= width) return basicString;
396 var buffer = new StringBuffer(); 396 var buffer = new StringBuffer();
397 for (var i = 0; i < width - basicString.length; i++) { 397 for (var i = 0; i < width - basicString.length; i++) {
398 buffer.add('0'); 398 buffer.add('0');
399 } 399 }
400 buffer.add(basicString); 400 buffer.add(basicString);
401 return buffer.toString(); 401 return buffer.toString();
402 } 402 }
403 } 403 }
OLDNEW
« no previous file with comments | « pkg/intl/intl.dart ('k') | pkg/intl/number_format.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698