| 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 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 String formatMinutes(Date date) { | 371 String formatMinutes(Date date) { |
| 372 return padTo(width, date.minute); | 372 return padTo(width, date.minute); |
| 373 } | 373 } |
| 374 | 374 |
| 375 String formatSeconds(Date date) { | 375 String formatSeconds(Date date) { |
| 376 return padTo(width, date.second); | 376 return padTo(width, date.second); |
| 377 } | 377 } |
| 378 | 378 |
| 379 String formatTimeZoneId(Date date) { | 379 String formatTimeZoneId(Date date) { |
| 380 // TODO(alanknight): implement time zone support | 380 // TODO(alanknight): implement time zone support |
| 381 throw new NotImplementedException(); | 381 throw new UnimplementedError(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 String formatTimeZone(Date date) { | 384 String formatTimeZone(Date date) { |
| 385 throw new NotImplementedException(); | 385 throw new UnimplementedError(); |
| 386 } | 386 } |
| 387 | 387 |
| 388 String formatTimeZoneRFC(Date date) { | 388 String formatTimeZoneRFC(Date date) { |
| 389 throw new NotImplementedException(); | 389 throw new UnimplementedError(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 /** | 392 /** |
| 393 * Return a string representation of the object padded to the left with | 393 * Return a string representation of the object padded to the left with |
| 394 * zeros. Primarily useful for numbers. | 394 * zeros. Primarily useful for numbers. |
| 395 */ | 395 */ |
| 396 String padTo(int width, Object toBePrinted) { | 396 String padTo(int width, Object toBePrinted) { |
| 397 var basicString = toBePrinted.toString(); | 397 var basicString = toBePrinted.toString(); |
| 398 if (basicString.length >= width) return basicString; | 398 if (basicString.length >= width) return basicString; |
| 399 var buffer = new StringBuffer(); | 399 var buffer = new StringBuffer(); |
| 400 for (var i = 0; i < width - basicString.length; i++) { | 400 for (var i = 0; i < width - basicString.length; i++) { |
| 401 buffer.add('0'); | 401 buffer.add('0'); |
| 402 } | 402 } |
| 403 buffer.add(basicString); | 403 buffer.add(basicString); |
| 404 return buffer.toString(); | 404 return buffer.toString(); |
| 405 } | 405 } |
| 406 } | 406 } |
| OLD | NEW |