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 /** | 5 /** |
6 * This contains internal implementation details of the date formatting code | 6 * This contains internal implementation details of the date formatting code |
7 * which are exposed as public functions because they must be called by other | 7 * which are exposed as public functions because they must be called by other |
8 * libraries in order to configure the source for the locale data. We don't want | 8 * libraries in order to configure the source for the locale data. We don't want |
9 * them exposed as public API functions in the date formatting library, so they | 9 * them exposed as public API functions in the date formatting library, so they |
10 * are put in a separate library here. These are for internal use only. User | 10 * are put in a separate library here. These are for internal use only. User |
11 * code should import one of the `date_symbol_data...` libraries and call the | 11 * code should import one of the `date_symbol_data...` libraries and call the |
12 * `initializeDateFormatting` method exposed there. | 12 * `initializeDateFormatting` method exposed there. |
13 */ | 13 */ |
14 | 14 |
15 library date_format_internal; | 15 library date_format_internal; |
16 import 'intl_helpers.dart'; | 16 import 'intl_helpers.dart'; |
| 17 import '../date_symbols.dart'; |
17 | 18 |
18 /** | 19 /** |
19 * This holds the symbols to be used for date/time formatting, indexed | 20 * This holds the symbols to be used for date/time formatting, indexed |
20 * by locale. Note that it will be set differently during initialization, | 21 * by locale. Note that it will be set differently during initialization, |
21 * depending on what implementation we are using. By default, it is initialized | 22 * depending on what implementation we are using. By default, it is initialized |
22 * to an instance of UninitializedLocaleData, so any attempt to use it will | 23 * to an instance of UninitializedLocaleData, so any attempt to use it will |
23 * result in an informative error message. | 24 * result in an informative error message. |
24 */ | 25 */ |
25 var dateTimeSymbols = | 26 var dateTimeSymbols = |
26 const UninitializedLocaleData('initializeDateFormatting(<locale>)'); | 27 new UninitializedLocaleData('initializeDateFormatting(<locale>)', |
| 28 en_USSymbols); |
27 | 29 |
28 /** | 30 /** |
29 * This holds the patterns used for date/time formatting, indexed | 31 * This holds the patterns used for date/time formatting, indexed |
30 * by locale. Note that it will be set differently during initialization, | 32 * by locale. Note that it will be set differently during initialization, |
31 * depending on what implementation we are using. By default, it is initialized | 33 * depending on what implementation we are using. By default, it is initialized |
32 * to an instance of UninitializedLocaleData, so any attempt to use it will | 34 * to an instance of UninitializedLocaleData, so any attempt to use it will |
33 * result in an informative error message. | 35 * result in an informative error message. |
34 */ | 36 */ |
35 var dateTimePatterns = | 37 var dateTimePatterns = |
36 const UninitializedLocaleData('initializeDateFormatting(<locale>)'); | 38 new UninitializedLocaleData('initializeDateFormatting(<locale>)', |
| 39 en_USPatterns); |
37 | 40 |
38 /** | 41 /** |
39 * Initialize the symbols dictionary. This should be passed a function that | 42 * Initialize the symbols dictionary. This should be passed a function that |
40 * creates and returns the symbol data. We take a function so that if | 43 * creates and returns the symbol data. We take a function so that if |
41 * initializing the data is an expensive operation it need only be done once, | 44 * initializing the data is an expensive operation it need only be done once, |
42 * no matter how many times this method is called. | 45 * no matter how many times this method is called. |
43 */ | 46 */ |
44 void initializeDateSymbols(Function symbols) { | 47 void initializeDateSymbols(Function symbols) { |
45 if (dateTimeSymbols is UninitializedLocaleData) { | 48 if (dateTimeSymbols is UninitializedLocaleData) { |
46 dateTimeSymbols = symbols(); | 49 dateTimeSymbols = symbols(); |
47 } | 50 } |
48 } | 51 } |
49 | 52 |
50 /** | 53 /** |
51 * Initialize the patterns dictionary. This should be passed a function that | 54 * Initialize the patterns dictionary. This should be passed a function that |
52 * creates and returns the pattern data. We take a function so that if | 55 * creates and returns the pattern data. We take a function so that if |
53 * initializing the data is an expensive operation it need only be done once, | 56 * initializing the data is an expensive operation it need only be done once, |
54 * no matter how many times this method is called. | 57 * no matter how many times this method is called. |
55 */ | 58 */ |
56 void initializeDatePatterns(Function patterns) { | 59 void initializeDatePatterns(Function patterns) { |
57 if (dateTimePatterns is UninitializedLocaleData) { | 60 if (dateTimePatterns is UninitializedLocaleData) { |
58 dateTimePatterns = patterns(); | 61 dateTimePatterns = patterns(); |
59 } | 62 } |
60 } | 63 } |
61 | 64 |
62 Future initializeIndividualLocaleDateFormatting(Function init) { | 65 Future initializeIndividualLocaleDateFormatting(Function init) { |
63 return init(dateTimeSymbols, dateTimePatterns); | 66 return init(dateTimeSymbols, dateTimePatterns); |
64 } | 67 } |
OLD | NEW |