| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 * for details. All rights reserved. Use of this source code is governed by a | 3 * for details. All rights reserved. Use of this source code is governed by a |
| 4 * BSD-style license that can be found in the LICENSE file. | 4 * BSD-style license that can be found in the LICENSE file. |
| 5 * | 5 * |
| 6 * DateFormat is for formatting and parsing dates in a locale-sensitive | 6 * DateFormat is for formatting and parsing dates in a locale-sensitive |
| 7 * manner. | 7 * manner. |
| 8 * It allows the user to use any customized pattern to parse or format | 8 * It allows the user to use any customized pattern to parse or format |
| 9 * date-time strings under certain locales. Date elements that vary across | 9 * date-time strings under certain locales. Date elements that vary across |
| 10 * locales include month name, weekname, field, order, etc. | 10 * locales include month name, weekname, field, order, etc. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 static final int _longTime = 5; | 118 static final int _longTime = 5; |
| 119 static final int _mediumTime = 6; | 119 static final int _mediumTime = 6; |
| 120 static final int _shortTime = 7; | 120 static final int _shortTime = 7; |
| 121 static final int _fullDateTime = 8; | 121 static final int _fullDateTime = 8; |
| 122 static final int _longDateTime = 9; | 122 static final int _longDateTime = 9; |
| 123 static final int _mediumDateTime = 10; | 123 static final int _mediumDateTime = 10; |
| 124 static final int _shortDateTime = 11; | 124 static final int _shortDateTime = 11; |
| 125 | 125 |
| 126 /** | 126 /** |
| 127 * Named constructors for each of the above values. | 127 * Named constructors for each of the above values. |
| 128 * These could probably be made shorter if we just set the format to the | |
| 129 * constant and the parsing was lazy. | |
| 130 */ | 128 */ |
| 131 DateFormat.fullDate() : this.formatDefinition = _fullDate; | 129 DateFormat.fullDate() : this.formatDefinition = _fullDate; |
| 132 DateFormat.longDate() : this.formatDefinition = _longDate; | 130 DateFormat.longDate() : this.formatDefinition = _longDate; |
| 133 DateFormat.mediumDate() : this.formatDefinition = _mediumDate; | 131 DateFormat.mediumDate() : this.formatDefinition = _mediumDate; |
| 134 DateFormat.shortDate() : this.formatDefinition = _shortDate; | 132 DateFormat.shortDate() : this.formatDefinition = _shortDate; |
| 135 DateFormat.fullTime() : this.formatDefinition = _fullTime; | 133 DateFormat.fullTime() : this.formatDefinition = _fullTime; |
| 136 DateFormat.longTime() : this.formatDefinition = _longTime; | 134 DateFormat.longTime() : this.formatDefinition = _longTime; |
| 137 DateFormat.mediumTime() : this.formatDefinition = _mediumTime; | 135 DateFormat.mediumTime() : this.formatDefinition = _mediumTime; |
| 138 DateFormat.shortTime() : this.formatDefinition = _shortTime; | 136 DateFormat.shortTime() : this.formatDefinition = _shortTime; |
| 139 DateFormat.fullDateTime() : this.formatDefinition = _fullDateTime; | 137 DateFormat.fullDateTime() : this.formatDefinition = _fullDateTime; |
| 140 DateFormat.longDateTime() : this.formatDefinition = _longDateTime; | 138 DateFormat.longDateTime() : this.formatDefinition = _longDateTime; |
| 141 DateFormat.mediumDateTime() : this.formatDefinition = _mediumDateTime; | 139 DateFormat.mediumDateTime() : this.formatDefinition = _mediumDateTime; |
| 142 DateFormat.shortDateTime() : this.formatDefinition = _shortDateTime; | 140 DateFormat.shortDateTime() : this.formatDefinition = _shortDateTime; |
| 141 |
| 142 /** |
| 143 * Explicit constructor given a particular format |
| 144 **/ |
| 145 DateFormat(this.formatDefinition); |
| 143 | 146 |
| 144 DateFormat(this.formatDefinition); | 147 /** |
| 148 * Constructors for dates/times that use a default format. |
| 149 **/ |
| 150 DateFormat.date() {formatDefinition = _fullDate;} |
| 151 DateFormat.time() {formatDefinition = _fullTime;} |
| 152 DateFormat.dateTime() {formatDefinition = _fullDateTime;} |
| 145 | 153 |
| 146 /** | 154 /** |
| 147 * | 155 * |
| 148 */ | 156 */ |
| 149 String parse(String inputString) { | 157 String parse(String inputString) { |
| 150 return inputString; | 158 return inputString; |
| 151 } | 159 } |
| 152 | 160 |
| 153 /** | 161 /** |
| 154 * Format the given [date] object according to preset pattern and current | 162 * Format the given [date] object according to preset pattern and current |
| 155 * locale and return a formated string for the given date. | 163 * locale and return a formated string for the given date. |
| 156 */ | 164 */ |
| 157 String format(Date date, [TimeZone timeZone]) { | 165 String format(Date date, [TimeZone timeZone]) { |
| 158 // TODO(efortuna): optional TimeZone argument? TimeZone is deprecated... | 166 // TODO(efortuna): optional TimeZone argument? TimeZone is deprecated... |
| 159 return date.toString(); | 167 return date.toString(); |
| 160 } | 168 } |
| 161 } | 169 } |
| OLD | NEW |