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 // TODO(efortuna): Customized pattern system -- suggested by i18n needs |
| 8 // feedback on appropriateness. |
7 /** | 9 /** |
8 * DateFormat is for formatting and parsing dates in a locale-sensitive | 10 * DateFormat is for formatting and parsing dates in a locale-sensitive |
9 * manner. | 11 * manner. |
10 * It allows the user to choose from a set of standard date time formats as well | 12 * It allows the user to choose from a set of standard date time formats as well |
11 * as specify a customized pattern under certain locales. Date elements that | 13 * as specify a customized pattern under certain locales. Date elements that |
12 * vary across locales include month name, week name, field order, etc. | 14 * vary across locales include month name, week name, field order, etc. |
13 * <!-- TODO(efortuna): Customized pattern system -- suggested by i18n needs | |
14 * feedback on appropriateness. --> | |
15 * We also allow the user to use any customized pattern to parse or format | 15 * We also allow the user to use any customized pattern to parse or format |
16 * date-time strings under certain locales. Date elements that vary across | 16 * date-time strings under certain locales. Date elements that vary across |
17 * locales include month name, weekname, field, order, etc. | 17 * locales include month name, weekname, field, order, etc. |
18 * | 18 * |
| 19 * The actual date for the locales must be obtained. This can currently be done |
| 20 * in one of three ways, determined by which library you import. If you only |
| 21 * want to use en_US formatting you can use it directly, as a copy of that |
| 22 * locale is hard-coded into the formatter. In all other cases, |
| 23 * the [initializeDateFormatting] method must be called and will return a future |
| 24 * that is complete once the locale data is available. The result of the future |
| 25 * isn't important, but the data for that locale is available to the date |
| 26 * formatting and parsing once it completes. |
| 27 * |
| 28 * The easiest option is that the data may be available locally, imported in a |
| 29 * library that contains data for all the locales. |
| 30 * import 'package:intl/date_symbol_data_local.dart'; |
| 31 * initializeDateFormatting("en_US", null).then((_) => runMyCode()); |
| 32 * |
| 33 * If we are running outside of a browser, we may want to read the data |
| 34 * from files in the file system. |
| 35 * import 'package:intl/date_symbol_data_file.dart'; |
| 36 * initializeDateFormatting("de_DE", null).then((_) => runMyCode()); |
| 37 * |
| 38 * If we are running in a browser, we may want to read the data from the |
| 39 * server using the XmlHttpRequest mechanism. |
| 40 * import 'package:intl/date_symbol_data_http_request.dart'; |
| 41 * initializeDateFormatting("pt_BR", null).then((_) => runMyCode()); |
| 42 * |
| 43 * The code in example/basic/basic_example.dart shows a full example of |
| 44 * using this mechanism. |
| 45 * |
| 46 * Once we have the locale data, we need to specify the particular format. |
19 * This library uses the ICU/JDK date/time pattern specification both for | 47 * This library uses the ICU/JDK date/time pattern specification both for |
20 * complete format specifications and also the abbreviated "skeleton" form | 48 * complete format specifications and also the abbreviated "skeleton" form |
21 * which can also adapt to different locales and is preferred where available. | 49 * which can also adapt to different locales and is preferred where available. |
22 * | 50 * |
23 * Skeletons: These can be specified either as the ICU constant name or as the | 51 * Skeletons: These can be specified either as the ICU constant name or as the |
24 * skeleton to which it resolves. The supported set of skeletons is as follows | 52 * skeleton to which it resolves. The supported set of skeletons is as follows |
25 * ICU Name Skeleton | 53 * ICU Name Skeleton |
26 * -------- -------- | 54 * -------- -------- |
27 * DAY d | 55 * DAY d |
28 * ABBR_WEEKDAY E | 56 * ABBR_WEEKDAY E |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 List _reverse(List list) { | 589 List _reverse(List list) { |
562 // TODO(alanknight): Use standardized list reverse when implemented. | 590 // TODO(alanknight): Use standardized list reverse when implemented. |
563 // See Issue 2804. | 591 // See Issue 2804. |
564 var result = new List(); | 592 var result = new List(); |
565 for (var i = list.length-1; i >= 0; i--) { | 593 for (var i = list.length-1; i >= 0; i--) { |
566 result.addLast(list[i]); | 594 result.addLast(list[i]); |
567 } | 595 } |
568 return result; | 596 return result; |
569 } | 597 } |
570 } | 598 } |
OLD | NEW |