| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 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 | |
| 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 | |
| 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 | |
| 12 * `initializeDateFormatting` method exposed there. | |
| 13 */ | |
| 14 | |
| 15 library date_format_internal; | |
| 16 import 'dart:async'; | |
| 17 import 'intl_helpers.dart'; | |
| 18 import '../date_symbols.dart'; | |
| 19 | |
| 20 /** | |
| 21 * This holds the symbols to be used for date/time formatting, indexed | |
| 22 * by locale. Note that it will be set differently during initialization, | |
| 23 * depending on what implementation we are using. By default, it is initialized | |
| 24 * to an instance of UninitializedLocaleData, so any attempt to use it will | |
| 25 * result in an informative error message. | |
| 26 */ | |
| 27 var dateTimeSymbols = | |
| 28 new UninitializedLocaleData('initializeDateFormatting(<locale>)', | |
| 29 en_USSymbols); | |
| 30 | |
| 31 /** | |
| 32 * This holds the patterns used for date/time formatting, indexed | |
| 33 * by locale. Note that it will be set differently during initialization, | |
| 34 * depending on what implementation we are using. By default, it is initialized | |
| 35 * to an instance of UninitializedLocaleData, so any attempt to use it will | |
| 36 * result in an informative error message. | |
| 37 */ | |
| 38 var dateTimePatterns = | |
| 39 new UninitializedLocaleData('initializeDateFormatting(<locale>)', | |
| 40 en_USPatterns); | |
| 41 | |
| 42 /** | |
| 43 * Initialize the symbols dictionary. This should be passed a function that | |
| 44 * creates and returns the symbol data. We take a function so that if | |
| 45 * initializing the data is an expensive operation it need only be done once, | |
| 46 * no matter how many times this method is called. | |
| 47 */ | |
| 48 void initializeDateSymbols(Function symbols) { | |
| 49 if (dateTimeSymbols is UninitializedLocaleData) { | |
| 50 dateTimeSymbols = symbols(); | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 /** | |
| 55 * Initialize the patterns dictionary. This should be passed a function that | |
| 56 * creates and returns the pattern data. We take a function so that if | |
| 57 * initializing the data is an expensive operation it need only be done once, | |
| 58 * no matter how many times this method is called. | |
| 59 */ | |
| 60 void initializeDatePatterns(Function patterns) { | |
| 61 if (dateTimePatterns is UninitializedLocaleData) { | |
| 62 dateTimePatterns = patterns(); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 Future initializeIndividualLocaleDateFormatting(Function init) { | |
| 67 return init(dateTimeSymbols, dateTimePatterns); | |
| 68 } | |
| OLD | NEW |