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

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

Issue 218493011: partly fix date format dartbug.com/15811. this 0 pads. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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/test/date_time_format_test_core.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 part of intl; 5 part of intl;
6 6
7 /** 7 /**
8 * This is a private class internal to DateFormat which is used for formatting 8 * This is a private class internal to DateFormat which is used for formatting
9 * particular fields in a template. e.g. if the format is hh:mm:ss then the 9 * particular fields in a template. e.g. if the format is hh:mm:ss then the
10 * fields would be "hh", ":", "mm", ":", and "ss". Each type of field knows 10 * fields would be "hh", ":", "mm", ":", and "ss". Each type of field knows
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 return width >= 4 ? symbols.ERANAMES[era] : 188 return width >= 4 ? symbols.ERANAMES[era] :
189 symbols.ERAS[era]; 189 symbols.ERAS[era];
190 } 190 }
191 191
192 formatYear(DateTime date) { 192 formatYear(DateTime date) {
193 // TODO(alanknight): Proper handling of years <= 0 193 // TODO(alanknight): Proper handling of years <= 0
194 var year = date.year; 194 var year = date.year;
195 if (year < 0) { 195 if (year < 0) {
196 year = -year; 196 year = -year;
197 } 197 }
198 return width == 2 ? padTo(2, year % 100) : year.toString(); 198 return width == 2 ? padTo(2, year % 100) : padTo(width, year);
199 } 199 }
200 200
201 /** 201 /**
202 * We are given [input] as a stream from which we want to read a date. We 202 * We are given [input] as a stream from which we want to read a date. We
203 * can't dynamically build up a date, so we are given a list [dateFields] of 203 * can't dynamically build up a date, so we are given a list [dateFields] of
204 * the constructor arguments and an [position] at which to set it 204 * the constructor arguments and an [position] at which to set it
205 * (year,month,day,hour,minute,second,fractionalSecond) 205 * (year,month,day,hour,minute,second,fractionalSecond)
206 * then after all parsing is done we construct a date from the arguments. 206 * then after all parsing is done we construct a date from the arguments.
207 * This method handles reading any of the numeric fields. The [offset] 207 * This method handles reading any of the numeric fields. The [offset]
208 * argument allows us to compensate for zero-based versus one-based values. 208 * argument allows us to compensate for zero-based versus one-based values.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 var basicString = toBePrinted.toString(); 426 var basicString = toBePrinted.toString();
427 if (basicString.length >= width) return basicString; 427 if (basicString.length >= width) return basicString;
428 var buffer = new StringBuffer(); 428 var buffer = new StringBuffer();
429 for (var i = 0; i < width - basicString.length; i++) { 429 for (var i = 0; i < width - basicString.length; i++) {
430 buffer.write('0'); 430 buffer.write('0');
431 } 431 }
432 buffer.write(basicString); 432 buffer.write(basicString);
433 return buffer.toString(); 433 return buffer.toString();
434 } 434 }
435 } 435 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/test/date_time_format_test_core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698