| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 String format24Hours(DateTime date) { | 253 String format24Hours(DateTime date) { |
| 254 return padTo(width, date.hour); | 254 return padTo(width, date.hour); |
| 255 } | 255 } |
| 256 | 256 |
| 257 String formatFractionalSeconds(DateTime date) { | 257 String formatFractionalSeconds(DateTime date) { |
| 258 // Always print at least 3 digits. If the width is greater, append 0s | 258 // Always print at least 3 digits. If the width is greater, append 0s |
| 259 var basic = padTo(3, date.millisecond); | 259 var basic = padTo(3, date.millisecond); |
| 260 if (width - 3 > 0) { | 260 if (width - 3 > 0) { |
| 261 var extra = padTo(width - 3, 0); | 261 var extra = padTo(width - 3, 0); |
| 262 return basic.concat(extra); | 262 return basic + extra; |
| 263 } else { | 263 } else { |
| 264 return basic; | 264 return basic; |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 | 267 |
| 268 String formatAmPm(DateTime date) { | 268 String formatAmPm(DateTime date) { |
| 269 var hours = date.hour; | 269 var hours = date.hour; |
| 270 var index = (date.hour >= 12) && (date.hour < 24) ? 1 : 0; | 270 var index = (date.hour >= 12) && (date.hour < 24) ? 1 : 0; |
| 271 var ampm = symbols.AMPMS; | 271 var ampm = symbols.AMPMS; |
| 272 return ampm[index]; | 272 return ampm[index]; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.write('0'); | 401 buffer.write('0'); |
| 402 } | 402 } |
| 403 buffer.write(basicString); | 403 buffer.write(basicString); |
| 404 return buffer.toString(); | 404 return buffer.toString(); |
| 405 } | 405 } |
| 406 } | 406 } |
| OLD | NEW |