Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: packages/intl/lib/src/date_format_internal.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /// This contains internal implementation details of the date formatting code
6 * This contains internal implementation details of the date formatting code 6 /// 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 7 /// libraries in order to configure the source for the locale data. We don't
8 * libraries in order to configure the source for the locale data. We don't want 8 /// want them exposed as public API functions in the date formatting library, so
9 * them exposed as public API functions in the date formatting library, so they 9 /// they are put in a separate library here. These are for internal use
10 * are put in a separate library here. These are for internal use only. User 10 /// only. User code should import one of the `date_symbol_data...` libraries and
11 * code should import one of the `date_symbol_data...` libraries and call the 11 /// call the `initializeDateFormatting` method exposed there.
12 * `initializeDateFormatting` method exposed there.
13 */
14 12
15 library date_format_internal; 13 library date_format_internal;
16 14
17 import 'dart:async'; 15 import 'dart:async';
18 import 'intl_helpers.dart'; 16 import 'intl_helpers.dart';
19 import '../date_symbols.dart'; 17 import '../date_symbols.dart';
20 18
21 /** 19 /// This holds the symbols to be used for date/time formatting, indexed
22 * This holds the symbols to be used for date/time formatting, indexed 20 /// by locale. Note that it will be set differently during initialization,
23 * by locale. Note that it will be set differently during initialization, 21 /// depending on what implementation we are using. By default, it is initialized
24 * 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
25 * to an instance of UninitializedLocaleData, so any attempt to use it will 23 /// result in an informative error message.
26 * result in an informative error message. 24 // TODO(alanknight): Have a valid type for this. Currently it can be an
27 */ 25 // UninitializedLocaleData, Map, or LazyLocaleData.
28 var dateTimeSymbols = new UninitializedLocaleData( 26 dynamic get dateTimeSymbols => _dateTimeSymbols;
27
28 /// Set the dateTimeSymbols and invalidate cache.
29 set dateTimeSymbols(dynamic symbols) {
30 // With all the mechanisms we have now this should be sufficient. We can
31 // have an UninitializedLocaleData which gives us the fallback locale, but
32 // when we replace it we invalidate. With a LazyLocaleData we won't change
33 // the results for a particular locale, it will just go from throwing to
34 // being available. With a Map everything is available.
35 _dateTimeSymbols = symbols;
36 cachedDateSymbols = null;
37 lastDateSymbolLocale = null;
38 }
39
40 dynamic _dateTimeSymbols = new UninitializedLocaleData(
29 'initializeDateFormatting(<locale>)', en_USSymbols); 41 'initializeDateFormatting(<locale>)', en_USSymbols);
30 42
31 /** 43 /// Cache the last used symbols to reduce repeated lookups.
32 * This holds the patterns used for date/time formatting, indexed 44 DateSymbols cachedDateSymbols;
33 * by locale. Note that it will be set differently during initialization, 45
34 * depending on what implementation we are using. By default, it is initialized 46 /// Which locale was last used for symbol lookup.
35 * to an instance of UninitializedLocaleData, so any attempt to use it will 47 String lastDateSymbolLocale;
36 * result in an informative error message. 48
37 */ 49 /// This holds the patterns used for date/time formatting, indexed
38 var dateTimePatterns = new UninitializedLocaleData( 50 /// by locale. Note that it will be set differently during initialization,
51 /// depending on what implementation we are using. By default, it is initialized
52 /// to an instance of UninitializedLocaleData, so any attempt to use it will
53 /// result in an informative error message.
54 // TODO(alanknight): Have a valid type for this. Currently it can be an
55 // UninitializedLocaleData, Map, or LazyLocaleData.
56 dynamic dateTimePatterns = new UninitializedLocaleData(
39 'initializeDateFormatting(<locale>)', en_USPatterns); 57 'initializeDateFormatting(<locale>)', en_USPatterns);
40 58
41 /** 59 /// Initialize the symbols dictionary. This should be passed a function that
42 * Initialize the symbols dictionary. This should be passed a function that 60 /// 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 61 /// 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, 62 /// no matter how many times this method is called.
45 * no matter how many times this method is called.
46 */
47 void initializeDateSymbols(Function symbols) { 63 void initializeDateSymbols(Function symbols) {
48 if (dateTimeSymbols is UninitializedLocaleData) { 64 if (dateTimeSymbols is UninitializedLocaleData) {
49 dateTimeSymbols = symbols(); 65 dateTimeSymbols = symbols();
50 } 66 }
51 } 67 }
52 68
53 /** 69 /// Initialize the patterns dictionary. This should be passed a function that
54 * Initialize the patterns dictionary. This should be passed a function that 70 /// 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 71 /// 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, 72 /// no matter how many times this method is called.
57 * no matter how many times this method is called.
58 */
59 void initializeDatePatterns(Function patterns) { 73 void initializeDatePatterns(Function patterns) {
60 if (dateTimePatterns is UninitializedLocaleData) { 74 if (dateTimePatterns is UninitializedLocaleData) {
61 dateTimePatterns = patterns(); 75 dateTimePatterns = patterns();
62 } 76 }
63 } 77 }
64 78
65 Future initializeIndividualLocaleDateFormatting(Function init) { 79 Future initializeIndividualLocaleDateFormatting(Function init) {
66 return init(dateTimeSymbols, dateTimePatterns); 80 return init(dateTimeSymbols, dateTimePatterns);
67 } 81 }
OLDNEW
« no previous file with comments | « packages/intl/lib/src/data/dates/symbols/zu.json ('k') | packages/intl/lib/src/file_data_reader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698