| 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 final String NAME; | 16 String NAME; |
| 17 final 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; |
| 22 final Map<String, String> AVAILABLEFORMATS; | 22 Map<String, String> AVAILABLEFORMATS; |
| 23 final int FIRSTDAYOFWEEK; | 23 int FIRSTDAYOFWEEK; |
| 24 final List<int> WEEKENDRANGE; | 24 List<int> WEEKENDRANGE; |
| 25 final int FIRSTWEEKCUTOFFDAY; | 25 int FIRSTWEEKCUTOFFDAY; |
| 26 | 26 |
| 27 const 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, |
| 32 this.MONTHS, | 32 this.MONTHS, |
| 33 this.STANDALONEMONTHS, | 33 this.STANDALONEMONTHS, |
| 34 this.SHORTMONTHS, | 34 this.SHORTMONTHS, |
| 35 this.STANDALONESHORTMONTHS, | 35 this.STANDALONESHORTMONTHS, |
| 36 this.WEEKDAYS, | 36 this.WEEKDAYS, |
| 37 this.STANDALONEWEEKDAYS, | 37 this.STANDALONEWEEKDAYS, |
| 38 this.SHORTWEEKDAYS, | 38 this.SHORTWEEKDAYS, |
| 39 this.STANDALONESHORTWEEKDAYS, | 39 this.STANDALONESHORTWEEKDAYS, |
| 40 this.NARROWWEEKDAYS, | 40 this.NARROWWEEKDAYS, |
| 41 this.STANDALONENARROWWEEKDAYS, | 41 this.STANDALONENARROWWEEKDAYS, |
| 42 this.SHORTQUARTERS, | 42 this.SHORTQUARTERS, |
| 43 this.QUARTERS, | 43 this.QUARTERS, |
| 44 this.AMPMS, | 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. |
| 45 this.DATEFORMATS, | 49 this.DATEFORMATS, |
| 46 this.TIMEFORMATS, | 50 this.TIMEFORMATS, |
| 47 this.AVAILABLEFORMATS, | 51 this.AVAILABLEFORMATS, |
| 48 this.FIRSTDAYOFWEEK, | 52 this.FIRSTDAYOFWEEK, |
| 49 this.WEEKENDRANGE, | 53 this.WEEKENDRANGE, |
| 50 this.FIRSTWEEKCUTOFFDAY]); | 54 this.FIRSTWEEKCUTOFFDAY]); |
| 51 | 55 |
| 56 // TODO(alanknight): Replace this with use of a more general serialization |
| 57 // facility once one is available. Issue 4926. |
| 58 DateSymbols.deserializeFromMap(Map map) { |
| 59 NAME = map["NAME"]; |
| 60 ERAS = map["ERAS"]; |
| 61 ERANAMES = map["ERANAMES"]; |
| 62 NARROWMONTHS = map["NARROWMONTHS"]; |
| 63 STANDALONENARROWMONTHS = map["STANDALONENARROWMONTHS"]; |
| 64 MONTHS = map["MONTHS"]; |
| 65 STANDALONEMONTHS = map["STANDALONEMONTHS"]; |
| 66 SHORTMONTHS = map["SHORTMONTHS"]; |
| 67 STANDALONESHORTMONTHS = map["STANDALONESHORTMONTHS"]; |
| 68 WEEKDAYS = map["WEEKDAYS"]; |
| 69 STANDALONEWEEKDAYS = map["STANDALONEWEEKDAYS"]; |
| 70 SHORTWEEKDAYS = map["SHORTWEEKDAYS"]; |
| 71 STANDALONESHORTWEEKDAYS = map["STANDALONESHORTWEEKDAYS"]; |
| 72 NARROWWEEKDAYS = map["NARROWWEEKDAYS"]; |
| 73 STANDALONENARROWWEEKDAYS = map["STANDALONENARROWWEEKDAYS"]; |
| 74 SHORTQUARTERS = map["SHORTQUARTERS"]; |
| 75 QUARTERS = map["QUARTERS"]; |
| 76 AMPMS = map["AMPMS"]; |
| 77 DATEFORMATS = map["DATEFORMATS"]; |
| 78 TIMEFORMATS = map["TIMEFORMATS"]; |
| 79 AVAILABLEFORMATS = map["AVAILABLEFORMATS"]; |
| 80 FIRSTDAYOFWEEK = map["FIRSTDAYOFWEEK"]; |
| 81 WEEKENDRANGE = map["WEEKENDRANGE"]; |
| 82 FIRSTWEEKCUTOFFDAY = map["FIRSTWEEKCUTOFFDAY"]; |
| 83 } |
| 84 |
| 85 Map serializeToMap() { |
| 86 var map = new Map(); |
| 87 map["NAME"] = NAME; |
| 88 map["ERAS"] = ERAS; |
| 89 map["ERANAMES"] = ERANAMES; |
| 90 map["NARROWMONTHS"] = NARROWMONTHS; |
| 91 map["STANDALONENARROWMONTHS"] = STANDALONENARROWMONTHS; |
| 92 map["MONTHS"] = MONTHS; |
| 93 map["STANDALONEMONTHS"] = STANDALONEMONTHS; |
| 94 map["SHORTMONTHS"] = SHORTMONTHS; |
| 95 map["STANDALONESHORTMONTHS"] = STANDALONESHORTMONTHS; |
| 96 map["WEEKDAYS"] = WEEKDAYS; |
| 97 map["STANDALONEWEEKDAYS"] = STANDALONEWEEKDAYS; |
| 98 map["SHORTWEEKDAYS"] = SHORTWEEKDAYS; |
| 99 map["STANDALONESHORTWEEKDAYS"] = STANDALONESHORTWEEKDAYS; |
| 100 map["NARROWWEEKDAYS"] = NARROWWEEKDAYS; |
| 101 map["STANDALONENARROWWEEKDAYS"] = STANDALONENARROWWEEKDAYS; |
| 102 map["SHORTQUARTERS"] = SHORTQUARTERS; |
| 103 map["QUARTERS"] = QUARTERS; |
| 104 map["AMPMS"] = AMPMS; |
| 105 map["DATEFORMATS"] = DATEFORMATS; |
| 106 map["TIMEFORMATS"] = TIMEFORMATS; |
| 107 map["AVAILABLEFORMATS"] = AVAILABLEFORMATS; |
| 108 map["FIRSTDAYOFWEEK"] = FIRSTDAYOFWEEK; |
| 109 map["WEEKENDRANGE"] = WEEKENDRANGE; |
| 110 map["FIRSTWEEKCUTOFFDAY"] = FIRSTWEEKCUTOFFDAY; |
| 111 return map; |
| 112 } |
| 113 |
| 52 toString() => NAME; | 114 toString() => NAME; |
| 53 } | 115 } |
| OLD | NEW |