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 library date_symbols; | |
5 | |
6 /** | |
7 * This holds onto information about how a particular locale formats dates. It | |
8 * contains mostly strings, e.g. what the names of months or weekdays are, | |
9 * but also indicates things like the first day of the week. We expect the data | |
10 * for instances of these to be generated out of ICU or a similar reference | |
11 * source. This is used in conjunction with the date_time_patterns, which | |
12 * defines for a particular locale the different named formats that will | |
13 * make use of this data. | |
14 */ | |
15 class DateSymbols { | |
16 String NAME; | |
17 List<String> ERAS, ERANAMES, NARROWMONTHS, STANDALONENARROWMONTHS, | |
18 MONTHS, STANDALONEMONTHS, SHORTMONTHS, STANDALONESHORTMONTHS, WEEKDAYS, | |
19 STANDALONEWEEKDAYS, SHORTWEEKDAYS, STANDALONESHORTWEEKDAYS, | |
20 NARROWWEEKDAYS, STANDALONENARROWWEEKDAYS, SHORTQUARTERS, | |
21 QUARTERS, AMPMS, DATEFORMATS, TIMEFORMATS, DATETIMEFORMATS; | |
22 Map<String, String> AVAILABLEFORMATS; | |
23 int FIRSTDAYOFWEEK; | |
24 List<int> WEEKENDRANGE; | |
25 int FIRSTWEEKCUTOFFDAY; | |
26 | |
27 DateSymbols({this.NAME, | |
28 this.ERAS, | |
29 this.ERANAMES, | |
30 this.NARROWMONTHS, | |
31 this.STANDALONENARROWMONTHS, | |
32 this.MONTHS, | |
33 this.STANDALONEMONTHS, | |
34 this.SHORTMONTHS, | |
35 this.STANDALONESHORTMONTHS, | |
36 this.WEEKDAYS, | |
37 this.STANDALONEWEEKDAYS, | |
38 this.SHORTWEEKDAYS, | |
39 this.STANDALONESHORTWEEKDAYS, | |
40 this.NARROWWEEKDAYS, | |
41 this.STANDALONENARROWWEEKDAYS, | |
42 this.SHORTQUARTERS, | |
43 this.QUARTERS, | |
44 this.AMPMS, | |
45 // TODO(alanknight): These formats are taken from Closure, | |
46 // where there's only a fixed set of available formats. | |
47 // Here we have the patterns separately. These should | |
48 // either be used, or removed. | |
49 this.DATEFORMATS, | |
50 this.TIMEFORMATS, | |
51 this.AVAILABLEFORMATS, | |
52 this.FIRSTDAYOFWEEK, | |
53 this.WEEKENDRANGE, | |
54 this.FIRSTWEEKCUTOFFDAY, | |
55 this.DATETIMEFORMATS}); | |
56 | |
57 // TODO(alanknight): Replace this with use of a more general serialization | |
58 // facility once one is available. Issue 4926. | |
59 DateSymbols.deserializeFromMap(Map map) { | |
60 NAME = map["NAME"]; | |
61 ERAS = map["ERAS"]; | |
62 ERANAMES = map["ERANAMES"]; | |
63 NARROWMONTHS = map["NARROWMONTHS"]; | |
64 STANDALONENARROWMONTHS = map["STANDALONENARROWMONTHS"]; | |
65 MONTHS = map["MONTHS"]; | |
66 STANDALONEMONTHS = map["STANDALONEMONTHS"]; | |
67 SHORTMONTHS = map["SHORTMONTHS"]; | |
68 STANDALONESHORTMONTHS = map["STANDALONESHORTMONTHS"]; | |
69 WEEKDAYS = map["WEEKDAYS"]; | |
70 STANDALONEWEEKDAYS = map["STANDALONEWEEKDAYS"]; | |
71 SHORTWEEKDAYS = map["SHORTWEEKDAYS"]; | |
72 STANDALONESHORTWEEKDAYS = map["STANDALONESHORTWEEKDAYS"]; | |
73 NARROWWEEKDAYS = map["NARROWWEEKDAYS"]; | |
74 STANDALONENARROWWEEKDAYS = map["STANDALONENARROWWEEKDAYS"]; | |
75 SHORTQUARTERS = map["SHORTQUARTERS"]; | |
76 QUARTERS = map["QUARTERS"]; | |
77 AMPMS = map["AMPMS"]; | |
78 DATEFORMATS = map["DATEFORMATS"]; | |
79 TIMEFORMATS = map["TIMEFORMATS"]; | |
80 AVAILABLEFORMATS = map["AVAILABLEFORMATS"]; | |
81 FIRSTDAYOFWEEK = map["FIRSTDAYOFWEEK"]; | |
82 WEEKENDRANGE = map["WEEKENDRANGE"]; | |
83 FIRSTWEEKCUTOFFDAY = map["FIRSTWEEKCUTOFFDAY"]; | |
84 DATETIMEFORMATS = map["DATETIMEFORAMTS"]; | |
85 } | |
86 | |
87 Map serializeToMap() => { | |
88 "NAME": NAME, | |
89 "ERAS": ERAS, | |
90 "ERANAMES": ERANAMES, | |
91 "NARROWMONTHS": NARROWMONTHS, | |
92 "STANDALONENARROWMONTHS": STANDALONENARROWMONTHS, | |
93 "MONTHS": MONTHS, | |
94 "STANDALONEMONTHS": STANDALONEMONTHS, | |
95 "SHORTMONTHS": SHORTMONTHS, | |
96 "STANDALONESHORTMONTHS": STANDALONESHORTMONTHS, | |
97 "WEEKDAYS": WEEKDAYS, | |
98 "STANDALONEWEEKDAYS": STANDALONEWEEKDAYS, | |
99 "SHORTWEEKDAYS": SHORTWEEKDAYS, | |
100 "STANDALONESHORTWEEKDAYS": STANDALONESHORTWEEKDAYS, | |
101 "NARROWWEEKDAYS": NARROWWEEKDAYS, | |
102 "STANDALONENARROWWEEKDAYS": STANDALONENARROWWEEKDAYS, | |
103 "SHORTQUARTERS": SHORTQUARTERS, | |
104 "QUARTERS": QUARTERS, | |
105 "AMPMS": AMPMS, | |
106 "DATEFORMATS": DATEFORMATS, | |
107 "TIMEFORMATS": TIMEFORMATS, | |
108 "AVAILABLEFORMATS": AVAILABLEFORMATS, | |
109 "FIRSTDAYOFWEEK": FIRSTDAYOFWEEK, | |
110 "WEEKENDRANGE": WEEKENDRANGE, | |
111 "FIRSTWEEKCUTOFFDAY": FIRSTWEEKCUTOFFDAY, | |
112 "DATETIMEFORMATS" : DATETIMEFORMATS, | |
113 }; | |
114 | |
115 toString() => NAME; | |
116 } | |
117 | |
118 /** | |
119 * We hard-code the locale data for en_US here so that there's at least one | |
120 * locale always available. | |
121 */ | |
122 var en_USSymbols = new DateSymbols( | |
123 NAME: "en_US", | |
124 ERAS: const [ 'BC', 'AD'], | |
125 ERANAMES: const [ 'Before Christ', 'Anno Domini'], | |
126 NARROWMONTHS: const [ 'J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', | |
127 'N', 'D'], | |
128 STANDALONENARROWMONTHS: const [ 'J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', | |
129 'S', 'O', 'N', 'D'], | |
130 MONTHS: const [ 'January', 'February', 'March', 'April', 'May', 'June', | |
131 'July', 'August', 'September', 'October', 'November', 'December'], | |
132 STANDALONEMONTHS: const [ 'January', 'February', 'March', 'April', 'May', | |
133 'June', 'July', 'August', 'September', 'October', 'November', | |
134 'December'], | |
135 SHORTMONTHS: const [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', | |
136 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], | |
137 STANDALONESHORTMONTHS: const [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', | |
138 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], | |
139 WEEKDAYS: const [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', | |
140 'Friday', 'Saturday'], | |
141 STANDALONEWEEKDAYS: const [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', | |
142 'Thursday', 'Friday', 'Saturday'], | |
143 SHORTWEEKDAYS: const [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], | |
144 STANDALONESHORTWEEKDAYS: const [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', | |
145 'Sat'], | |
146 NARROWWEEKDAYS: const [ 'S', 'M', 'T', 'W', 'T', 'F', 'S'], | |
147 STANDALONENARROWWEEKDAYS: const [ 'S', 'M', 'T', 'W', 'T', 'F', 'S'], | |
148 SHORTQUARTERS: const [ 'Q1', 'Q2', 'Q3', 'Q4'], | |
149 QUARTERS: const [ '1st quarter', '2nd quarter', '3rd quarter', | |
150 '4th quarter'], | |
151 AMPMS: const [ 'AM', 'PM'], | |
152 DATEFORMATS: const [ 'EEEE, MMMM d, y', 'MMMM d, y', 'MMM d, y', | |
153 'M/d/yy'], | |
154 TIMEFORMATS: const [ 'h:mm:ss a zzzz', 'h:mm:ss a z', 'h:mm:ss a', | |
155 'h:mm a'], | |
156 FIRSTDAYOFWEEK: 6, | |
157 WEEKENDRANGE: const [5, 6], | |
158 FIRSTWEEKCUTOFFDAY: 5, | |
159 DATETIMEFORMATS: const ['{1} \'at\' {0}', '{1} \'at\' {0}', '{1}, {0}', | |
160 '{1}, {0}']); | |
161 | |
162 var en_USPatterns = const { | |
163 'd': 'd', // DAY | |
164 'E': 'EEE', // ABBR_WEEKDAY | |
165 'EEEE': 'EEEE', // WEEKDAY | |
166 'LLL': 'LLL', // ABBR_STANDALONE_MONTH | |
167 'LLLL': 'LLLL', // STANDALONE_MONTH | |
168 'M': 'L', // NUM_MONTH | |
169 'Md': 'M/d', // NUM_MONTH_DAY | |
170 'MEd': 'EEE, M/d', // NUM_MONTH_WEEKDAY_DAY | |
171 'MMM': 'LLL', // ABBR_MONTH | |
172 'MMMd': 'MMM d', // ABBR_MONTH_DAY | |
173 'MMMEd': 'EEE, MMM d', // ABBR_MONTH_WEEKDAY_DAY | |
174 'MMMM': 'LLLL', // MONTH | |
175 'MMMMd': 'MMMM d', // MONTH_DAY | |
176 'MMMMEEEEd': 'EEEE, MMMM d', // MONTH_WEEKDAY_DAY | |
177 'QQQ': 'QQQ', // ABBR_QUARTER | |
178 'QQQQ': 'QQQQ', // QUARTER | |
179 'y': 'y', // YEAR | |
180 'yM': 'M/y', // YEAR_NUM_MONTH | |
181 'yMd': 'M/d/y', // YEAR_NUM_MONTH_DAY | |
182 'yMEd': 'EEE, M/d/y', // YEAR_NUM_MONTH_WEEKDAY_DAY | |
183 'yMMM': 'MMM y', // YEAR_ABBR_MONTH | |
184 'yMMMd': 'MMM d, y', // YEAR_ABBR_MONTH_DAY | |
185 'yMMMEd': 'EEE, MMM d, y', // YEAR_ABBR_MONTH_WEEKDAY_DAY | |
186 'yMMMM': 'MMMM y', // YEAR_MONTH | |
187 'yMMMMd': 'MMMM d, y', // YEAR_MONTH_DAY | |
188 'yMMMMEEEEd': 'EEEE, MMMM d, y', // YEAR_MONTH_WEEKDAY_DAY | |
189 'yQQQ': 'QQQ y', // YEAR_ABBR_QUARTER | |
190 'yQQQQ': 'QQQQ y', // YEAR_QUARTER | |
191 'H': 'HH', // HOUR24 | |
192 'Hm': 'HH:mm', // HOUR24_MINUTE | |
193 'Hms': 'HH:mm:ss', // HOUR24_MINUTE_SECOND | |
194 'j': 'h a', // HOUR | |
195 'jm': 'h:mm a', // HOUR_MINUTE | |
196 'jms': 'h:mm:ss a', // HOUR_MINUTE_SECOND | |
197 'jmv': 'h:mm a v', // HOUR_MINUTE_GENERIC_TZ | |
198 'jmz': 'h:mm a z', // HOUR_MINUTETZ | |
199 'jz': 'h a z', // HOURGENERIC_TZ | |
200 'm': 'm', // MINUTE | |
201 'ms': 'mm:ss', // MINUTE_SECOND | |
202 's': 's', // SECOND | |
203 'v': 'v', // ABBR_GENERIC_TZ | |
204 'z': 'z', // ABBR_SPECIFIC_TZ | |
205 'zzzz': 'zzzz', // SPECIFIC_TZ | |
206 'ZZZZ': 'ZZZZ' // ABBR_UTC_TZ | |
207 }; | |
OLD | NEW |