| 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 library date_symbols; | 4 library date_symbols; |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * This holds onto information about how a particular locale formats dates. It | 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, | 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 | 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 | 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 | 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 | 12 * defines for a particular locale the different named formats that will |
| 13 * make use of this data. | 13 * make use of this data. |
| 14 */ | 14 */ |
| 15 class DateSymbols { | 15 class DateSymbols { |
| 16 String NAME; | 16 String NAME; |
| 17 List<String> ERAS, ERANAMES, NARROWMONTHS, STANDALONENARROWMONTHS, | 17 List<String> ERAS, ERANAMES, NARROWMONTHS, STANDALONENARROWMONTHS, |
| 18 MONTHS, STANDALONEMONTHS, SHORTMONTHS, STANDALONESHORTMONTHS, WEEKDAYS, | 18 MONTHS, STANDALONEMONTHS, SHORTMONTHS, STANDALONESHORTMONTHS, WEEKDAYS, |
| 19 STANDALONEWEEKDAYS, SHORTWEEKDAYS, STANDALONESHORTWEEKDAYS, | 19 STANDALONEWEEKDAYS, SHORTWEEKDAYS, STANDALONESHORTWEEKDAYS, |
| 20 NARROWWEEKDAYS, STANDALONENARROWWEEKDAYS, SHORTQUARTERS, | 20 NARROWWEEKDAYS, STANDALONENARROWWEEKDAYS, SHORTQUARTERS, |
| 21 QUARTERS, AMPMS, DATEFORMATS, TIMEFORMATS; | 21 QUARTERS, AMPMS, DATEFORMATS, TIMEFORMATS, DATETIMEFORMATS; |
| 22 Map<String, String> AVAILABLEFORMATS; | 22 Map<String, String> AVAILABLEFORMATS; |
| 23 int FIRSTDAYOFWEEK; | 23 int FIRSTDAYOFWEEK; |
| 24 List<int> WEEKENDRANGE; | 24 List<int> WEEKENDRANGE; |
| 25 int FIRSTWEEKCUTOFFDAY; | 25 int FIRSTWEEKCUTOFFDAY; |
| 26 | 26 |
| 27 DateSymbols({this.NAME, | 27 DateSymbols({this.NAME, |
| 28 this.ERAS, | 28 this.ERAS, |
| 29 this.ERANAMES, | 29 this.ERANAMES, |
| 30 this.NARROWMONTHS, | 30 this.NARROWMONTHS, |
| 31 this.STANDALONENARROWMONTHS, | 31 this.STANDALONENARROWMONTHS, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 this.AMPMS, | 44 this.AMPMS, |
| 45 // TODO(alanknight): These formats are taken from Closure, | 45 // TODO(alanknight): These formats are taken from Closure, |
| 46 // where there's only a fixed set of available formats. | 46 // where there's only a fixed set of available formats. |
| 47 // Here we have the patterns separately. These should | 47 // Here we have the patterns separately. These should |
| 48 // either be used, or removed. | 48 // either be used, or removed. |
| 49 this.DATEFORMATS, | 49 this.DATEFORMATS, |
| 50 this.TIMEFORMATS, | 50 this.TIMEFORMATS, |
| 51 this.AVAILABLEFORMATS, | 51 this.AVAILABLEFORMATS, |
| 52 this.FIRSTDAYOFWEEK, | 52 this.FIRSTDAYOFWEEK, |
| 53 this.WEEKENDRANGE, | 53 this.WEEKENDRANGE, |
| 54 this.FIRSTWEEKCUTOFFDAY}); | 54 this.FIRSTWEEKCUTOFFDAY, |
| 55 this.DATETIMEFORMATS}); |
| 55 | 56 |
| 56 // TODO(alanknight): Replace this with use of a more general serialization | 57 // TODO(alanknight): Replace this with use of a more general serialization |
| 57 // facility once one is available. Issue 4926. | 58 // facility once one is available. Issue 4926. |
| 58 DateSymbols.deserializeFromMap(Map map) { | 59 DateSymbols.deserializeFromMap(Map map) { |
| 59 NAME = map["NAME"]; | 60 NAME = map["NAME"]; |
| 60 ERAS = map["ERAS"]; | 61 ERAS = map["ERAS"]; |
| 61 ERANAMES = map["ERANAMES"]; | 62 ERANAMES = map["ERANAMES"]; |
| 62 NARROWMONTHS = map["NARROWMONTHS"]; | 63 NARROWMONTHS = map["NARROWMONTHS"]; |
| 63 STANDALONENARROWMONTHS = map["STANDALONENARROWMONTHS"]; | 64 STANDALONENARROWMONTHS = map["STANDALONENARROWMONTHS"]; |
| 64 MONTHS = map["MONTHS"]; | 65 MONTHS = map["MONTHS"]; |
| 65 STANDALONEMONTHS = map["STANDALONEMONTHS"]; | 66 STANDALONEMONTHS = map["STANDALONEMONTHS"]; |
| 66 SHORTMONTHS = map["SHORTMONTHS"]; | 67 SHORTMONTHS = map["SHORTMONTHS"]; |
| 67 STANDALONESHORTMONTHS = map["STANDALONESHORTMONTHS"]; | 68 STANDALONESHORTMONTHS = map["STANDALONESHORTMONTHS"]; |
| 68 WEEKDAYS = map["WEEKDAYS"]; | 69 WEEKDAYS = map["WEEKDAYS"]; |
| 69 STANDALONEWEEKDAYS = map["STANDALONEWEEKDAYS"]; | 70 STANDALONEWEEKDAYS = map["STANDALONEWEEKDAYS"]; |
| 70 SHORTWEEKDAYS = map["SHORTWEEKDAYS"]; | 71 SHORTWEEKDAYS = map["SHORTWEEKDAYS"]; |
| 71 STANDALONESHORTWEEKDAYS = map["STANDALONESHORTWEEKDAYS"]; | 72 STANDALONESHORTWEEKDAYS = map["STANDALONESHORTWEEKDAYS"]; |
| 72 NARROWWEEKDAYS = map["NARROWWEEKDAYS"]; | 73 NARROWWEEKDAYS = map["NARROWWEEKDAYS"]; |
| 73 STANDALONENARROWWEEKDAYS = map["STANDALONENARROWWEEKDAYS"]; | 74 STANDALONENARROWWEEKDAYS = map["STANDALONENARROWWEEKDAYS"]; |
| 74 SHORTQUARTERS = map["SHORTQUARTERS"]; | 75 SHORTQUARTERS = map["SHORTQUARTERS"]; |
| 75 QUARTERS = map["QUARTERS"]; | 76 QUARTERS = map["QUARTERS"]; |
| 76 AMPMS = map["AMPMS"]; | 77 AMPMS = map["AMPMS"]; |
| 77 DATEFORMATS = map["DATEFORMATS"]; | 78 DATEFORMATS = map["DATEFORMATS"]; |
| 78 TIMEFORMATS = map["TIMEFORMATS"]; | 79 TIMEFORMATS = map["TIMEFORMATS"]; |
| 79 AVAILABLEFORMATS = map["AVAILABLEFORMATS"]; | 80 AVAILABLEFORMATS = map["AVAILABLEFORMATS"]; |
| 80 FIRSTDAYOFWEEK = map["FIRSTDAYOFWEEK"]; | 81 FIRSTDAYOFWEEK = map["FIRSTDAYOFWEEK"]; |
| 81 WEEKENDRANGE = map["WEEKENDRANGE"]; | 82 WEEKENDRANGE = map["WEEKENDRANGE"]; |
| 82 FIRSTWEEKCUTOFFDAY = map["FIRSTWEEKCUTOFFDAY"]; | 83 FIRSTWEEKCUTOFFDAY = map["FIRSTWEEKCUTOFFDAY"]; |
| 84 DATETIMEFORMATS = map["DATETIMEFORAMTS"]; |
| 83 } | 85 } |
| 84 | 86 |
| 85 Map serializeToMap() => { | 87 Map serializeToMap() => { |
| 86 "NAME": NAME, | 88 "NAME": NAME, |
| 87 "ERAS": ERAS, | 89 "ERAS": ERAS, |
| 88 "ERANAMES": ERANAMES, | 90 "ERANAMES": ERANAMES, |
| 89 "NARROWMONTHS": NARROWMONTHS, | 91 "NARROWMONTHS": NARROWMONTHS, |
| 90 "STANDALONENARROWMONTHS": STANDALONENARROWMONTHS, | 92 "STANDALONENARROWMONTHS": STANDALONENARROWMONTHS, |
| 91 "MONTHS": MONTHS, | 93 "MONTHS": MONTHS, |
| 92 "STANDALONEMONTHS": STANDALONEMONTHS, | 94 "STANDALONEMONTHS": STANDALONEMONTHS, |
| 93 "SHORTMONTHS": SHORTMONTHS, | 95 "SHORTMONTHS": SHORTMONTHS, |
| 94 "STANDALONESHORTMONTHS": STANDALONESHORTMONTHS, | 96 "STANDALONESHORTMONTHS": STANDALONESHORTMONTHS, |
| 95 "WEEKDAYS": WEEKDAYS, | 97 "WEEKDAYS": WEEKDAYS, |
| 96 "STANDALONEWEEKDAYS": STANDALONEWEEKDAYS, | 98 "STANDALONEWEEKDAYS": STANDALONEWEEKDAYS, |
| 97 "SHORTWEEKDAYS": SHORTWEEKDAYS, | 99 "SHORTWEEKDAYS": SHORTWEEKDAYS, |
| 98 "STANDALONESHORTWEEKDAYS": STANDALONESHORTWEEKDAYS, | 100 "STANDALONESHORTWEEKDAYS": STANDALONESHORTWEEKDAYS, |
| 99 "NARROWWEEKDAYS": NARROWWEEKDAYS, | 101 "NARROWWEEKDAYS": NARROWWEEKDAYS, |
| 100 "STANDALONENARROWWEEKDAYS": STANDALONENARROWWEEKDAYS, | 102 "STANDALONENARROWWEEKDAYS": STANDALONENARROWWEEKDAYS, |
| 101 "SHORTQUARTERS": SHORTQUARTERS, | 103 "SHORTQUARTERS": SHORTQUARTERS, |
| 102 "QUARTERS": QUARTERS, | 104 "QUARTERS": QUARTERS, |
| 103 "AMPMS": AMPMS, | 105 "AMPMS": AMPMS, |
| 104 "DATEFORMATS": DATEFORMATS, | 106 "DATEFORMATS": DATEFORMATS, |
| 105 "TIMEFORMATS": TIMEFORMATS, | 107 "TIMEFORMATS": TIMEFORMATS, |
| 106 "AVAILABLEFORMATS": AVAILABLEFORMATS, | 108 "AVAILABLEFORMATS": AVAILABLEFORMATS, |
| 107 "FIRSTDAYOFWEEK": FIRSTDAYOFWEEK, | 109 "FIRSTDAYOFWEEK": FIRSTDAYOFWEEK, |
| 108 "WEEKENDRANGE": WEEKENDRANGE, | 110 "WEEKENDRANGE": WEEKENDRANGE, |
| 109 "FIRSTWEEKCUTOFFDAY": FIRSTWEEKCUTOFFDAY | 111 "FIRSTWEEKCUTOFFDAY": FIRSTWEEKCUTOFFDAY, |
| 112 "DATETIMEFORMATS" : DATETIMEFORMATS, |
| 110 }; | 113 }; |
| 111 | 114 |
| 112 toString() => NAME; | 115 toString() => NAME; |
| 113 } | 116 } |
| 114 | 117 |
| 115 /** | 118 /** |
| 116 * We hard-code the locale data for en_US here so that there's at least one | 119 * We hard-code the locale data for en_US here so that there's at least one |
| 117 * locale always available. | 120 * locale always available. |
| 118 */ | 121 */ |
| 119 var en_USSymbols = new DateSymbols( | 122 var en_USSymbols = new DateSymbols( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 145 SHORTQUARTERS: const [ 'Q1', 'Q2', 'Q3', 'Q4'], | 148 SHORTQUARTERS: const [ 'Q1', 'Q2', 'Q3', 'Q4'], |
| 146 QUARTERS: const [ '1st quarter', '2nd quarter', '3rd quarter', | 149 QUARTERS: const [ '1st quarter', '2nd quarter', '3rd quarter', |
| 147 '4th quarter'], | 150 '4th quarter'], |
| 148 AMPMS: const [ 'AM', 'PM'], | 151 AMPMS: const [ 'AM', 'PM'], |
| 149 DATEFORMATS: const [ 'EEEE, MMMM d, y', 'MMMM d, y', 'MMM d, y', | 152 DATEFORMATS: const [ 'EEEE, MMMM d, y', 'MMMM d, y', 'MMM d, y', |
| 150 'M/d/yy'], | 153 'M/d/yy'], |
| 151 TIMEFORMATS: const [ 'h:mm:ss a zzzz', 'h:mm:ss a z', 'h:mm:ss a', | 154 TIMEFORMATS: const [ 'h:mm:ss a zzzz', 'h:mm:ss a z', 'h:mm:ss a', |
| 152 'h:mm a'], | 155 'h:mm a'], |
| 153 FIRSTDAYOFWEEK: 6, | 156 FIRSTDAYOFWEEK: 6, |
| 154 WEEKENDRANGE: const [5, 6], | 157 WEEKENDRANGE: const [5, 6], |
| 155 FIRSTWEEKCUTOFFDAY: 5); | 158 FIRSTWEEKCUTOFFDAY: 5, |
| 159 DATETIMEFORMATS: const ['{1} \'at\' {0}', '{1} \'at\' {0}', '{1}, {0}', |
| 160 '{1}, {0}']); |
| 156 | 161 |
| 157 var en_USPatterns = const { | 162 var en_USPatterns = const { |
| 158 'd': 'd', // DAY | 163 'd': 'd', // DAY |
| 159 'E': 'EEE', // ABBR_WEEKDAY | 164 'E': 'EEE', // ABBR_WEEKDAY |
| 160 'EEEE': 'EEEE', // WEEKDAY | 165 'EEEE': 'EEEE', // WEEKDAY |
| 161 'LLL': 'LLL', // ABBR_STANDALONE_MONTH | 166 'LLL': 'LLL', // ABBR_STANDALONE_MONTH |
| 162 'LLLL': 'LLLL', // STANDALONE_MONTH | 167 'LLLL': 'LLLL', // STANDALONE_MONTH |
| 163 'M': 'L', // NUM_MONTH | 168 'M': 'L', // NUM_MONTH |
| 164 'Md': 'M/d', // NUM_MONTH_DAY | 169 'Md': 'M/d', // NUM_MONTH_DAY |
| 165 'MEd': 'EEE, M/d', // NUM_MONTH_WEEKDAY_DAY | 170 'MEd': 'EEE, M/d', // NUM_MONTH_WEEKDAY_DAY |
| (...skipping 27 matching lines...) Expand all Loading... |
| 193 'jmz': 'h:mm a z', // HOUR_MINUTETZ | 198 'jmz': 'h:mm a z', // HOUR_MINUTETZ |
| 194 'jz': 'h a z', // HOURGENERIC_TZ | 199 'jz': 'h a z', // HOURGENERIC_TZ |
| 195 'm': 'm', // MINUTE | 200 'm': 'm', // MINUTE |
| 196 'ms': 'mm:ss', // MINUTE_SECOND | 201 'ms': 'mm:ss', // MINUTE_SECOND |
| 197 's': 's', // SECOND | 202 's': 's', // SECOND |
| 198 'v': 'v', // ABBR_GENERIC_TZ | 203 'v': 'v', // ABBR_GENERIC_TZ |
| 199 'z': 'z', // ABBR_SPECIFIC_TZ | 204 'z': 'z', // ABBR_SPECIFIC_TZ |
| 200 'zzzz': 'zzzz', // SPECIFIC_TZ | 205 'zzzz': 'zzzz', // SPECIFIC_TZ |
| 201 'ZZZZ': 'ZZZZ' // ABBR_UTC_TZ | 206 'ZZZZ': 'ZZZZ' // ABBR_UTC_TZ |
| 202 }; | 207 }; |
| OLD | NEW |