Chromium Code Reviews| 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 | 4 |
| 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 choose from a set of standard date time formats as well | 8 * It allows the user to choose from a set of standard date time formats as well |
| 9 * as specify a customized pattern under certain locales. Date elements that | 9 * as specify a customized pattern under certain locales. Date elements that |
| 10 * vary across locales include month name, week name, field order, etc. | 10 * vary across locales include month name, week name, field order, etc. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 static final String mediumTime = Hms; | 165 static final String mediumTime = Hms; |
| 166 static final String shortTime = Hm; | 166 static final String shortTime = Hm; |
| 167 static final String fullDateTime = '$fullDate$fullTime'; | 167 static final String fullDateTime = '$fullDate$fullTime'; |
| 168 static final String longDateTime = '$longDate$longTime'; | 168 static final String longDateTime = '$longDate$longTime'; |
| 169 static final String mediumDateTime = '$mediumDate$mediumTime'; | 169 static final String mediumDateTime = '$mediumDate$mediumTime'; |
| 170 static final String shortDateTime = '$shortDate$shortTime'; | 170 static final String shortDateTime = '$shortDate$shortTime'; |
| 171 | 171 |
| 172 /** | 172 /** |
| 173 * Constructors for dates/times that use a default format. | 173 * Constructors for dates/times that use a default format. |
| 174 */ | 174 */ |
| 175 DateFormat.Hm([this._locale]) : _formatDefinition = Hm; | 175 DateFormat.Hm([locale=this._locale]) : _formatDefinition = Hm; |
|
Alan Knight
2012/06/28 00:05:03
If this syntax works, ok, but I don't understand i
| |
| 176 DateFormat.Hms([this._locale]) : _formatDefinition = Hms; | 176 DateFormat.Hms([locale=this._locale]) : _formatDefinition = Hms; |
| 177 DateFormat.M([this._locale]) : _formatDefinition = M; | 177 DateFormat.M([locale=this._locale]) : _formatDefinition = M; |
| 178 DateFormat.MEd([this._locale]) : _formatDefinition = MEd; | 178 DateFormat.MEd([locale=this._locale]) : _formatDefinition = MEd; |
| 179 DateFormat.MMM([this._locale]) : _formatDefinition = MMM; | 179 DateFormat.MMM([locale=this._locale]) : _formatDefinition = MMM; |
| 180 DateFormat.MMMEd([this._locale]) : _formatDefinition = MMMEd; | 180 DateFormat.MMMEd([locale=this._locale]) : _formatDefinition = MMMEd; |
| 181 DateFormat.MMMMEd([this._locale]) : _formatDefinition = MMMMEd; | 181 DateFormat.MMMMEd([locale=this._locale]) : _formatDefinition = MMMMEd; |
| 182 DateFormat.MMMMd([this._locale]) : _formatDefinition = MMMMd; | 182 DateFormat.MMMMd([locale=this._locale]) : _formatDefinition = MMMMd; |
| 183 DateFormat.MMMd([this._locale]) : _formatDefinition = MMMd; | 183 DateFormat.MMMd([locale=this._locale]) : _formatDefinition = MMMd; |
| 184 DateFormat.Md([this._locale]) : _formatDefinition = Md; | 184 DateFormat.Md([locale=this._locale]) : _formatDefinition = Md; |
| 185 DateFormat.d([this._locale]) : _formatDefinition = d; | 185 DateFormat.d([locale=this._locale]) : _formatDefinition = d; |
| 186 DateFormat.hm([this._locale]) : _formatDefinition = hm; | 186 DateFormat.hm([locale=this._locale]) : _formatDefinition = hm; |
| 187 DateFormat.ms([this._locale]) : _formatDefinition = ms; | 187 DateFormat.ms([locale=this._locale]) : _formatDefinition = ms; |
| 188 DateFormat.y([this._locale]) : _formatDefinition = y; | 188 DateFormat.y([locale=this._locale]) : _formatDefinition = y; |
| 189 DateFormat.yM([this._locale]) : _formatDefinition = yM; | 189 DateFormat.yM([locale=this._locale]) : _formatDefinition = yM; |
| 190 DateFormat.yMEd([this._locale]) : _formatDefinition = yMEd; | 190 DateFormat.yMEd([locale=this._locale]) : _formatDefinition = yMEd; |
| 191 DateFormat.yMMM([this._locale]) : _formatDefinition = yMMM; | 191 DateFormat.yMMM([locale=this._locale]) : _formatDefinition = yMMM; |
| 192 DateFormat.yMMMEd([this._locale]) : _formatDefinition = yMMMEd; | 192 DateFormat.yMMMEd([locale=this._locale]) : _formatDefinition = yMMMEd; |
| 193 DateFormat.yMMMM([this._locale]) : _formatDefinition = yMMMM; | 193 DateFormat.yMMMM([locale=this._locale]) : _formatDefinition = yMMMM; |
| 194 DateFormat.yQ([this._locale]) : _formatDefinition = yQ; | 194 DateFormat.yQ([locale=this._locale]) : _formatDefinition = yQ; |
| 195 DateFormat.yQQQ([this._locale]) : _formatDefinition = yQQQ; | 195 DateFormat.yQQQ([locale=this._locale]) : _formatDefinition = yQQQ; |
| 196 | 196 |
| 197 DateFormat.fullDate([this._locale]) : _formatDefinition = fullDate; | 197 DateFormat.fullDate([locale=this._locale]) : _formatDefinition = fullDate; |
| 198 DateFormat.longDate([this._locale]) : _formatDefinition = longDate; | 198 DateFormat.longDate([locale=this._locale]) : _formatDefinition = longDate; |
| 199 DateFormat.mediumDate([this._locale]) : _formatDefinition = mediumDate; | 199 DateFormat.mediumDate([locale=this._locale]) : _formatDefinition = mediumDate; |
| 200 DateFormat.shortDate([this._locale]) : _formatDefinition = shortDate; | 200 DateFormat.shortDate([locale=this._locale]) : _formatDefinition = shortDate; |
| 201 DateFormat.fullTime([this._locale]) : _formatDefinition = fullTime; | 201 DateFormat.fullTime([locale=this._locale]) : _formatDefinition = fullTime; |
| 202 DateFormat.longTime([this._locale]) : _formatDefinition = longTime; | 202 DateFormat.longTime([locale=this._locale]) : _formatDefinition = longTime; |
| 203 DateFormat.mediumTime([this._locale]) : _formatDefinition = mediumTime; | 203 DateFormat.mediumTime([locale=this._locale]) : _formatDefinition = mediumTime; |
| 204 DateFormat.shortTime([this._locale]) : _formatDefinition = shortTime; | 204 DateFormat.shortTime([locale=this._locale]) : _formatDefinition = shortTime; |
| 205 DateFormat.fullDateTime([this._locale]) : _formatDefinition = fullDateTime; | 205 DateFormat.fullDateTime([locale=this._locale]) : |
| 206 DateFormat.longDateTime([this._locale]) : _formatDefinition = longDateTime; | 206 _formatDefinition = fullDateTime; |
| 207 DateFormat.mediumDateTime([this._locale]) : _formatDefinition = mediumDateTime ; | 207 DateFormat.longDateTime([locale=this._locale]) : |
| 208 DateFormat.shortDateTime([this._locale]) : _formatDefinition = shortDateTime; | 208 _formatDefinition = longDateTime; |
| 209 DateFormat.mediumDateTime([locale=this._locale]) : | |
| 210 _formatDefinition = mediumDateTime; | |
| 211 DateFormat.shortDateTime([locale=this._locale]) : | |
| 212 _formatDefinition = shortDateTime; | |
| 209 | 213 |
| 210 /** | 214 /** |
| 211 * Constructor accepts a [formatDefinition], which can be a String, one of the | 215 * Constructor accepts a [formatDefinition], which can be a String, one of the |
| 212 * predefined static forms, or a custom date format using the syntax described | 216 * predefined static forms, or a custom date format using the syntax described |
| 213 * above. An optional [locale] can be provided for specifics of the language | 217 * above. An optional [locale] can be provided for specifics of the language |
| 214 * locale to be used, otherwise, we will attempt to infer it (acceptable if | 218 * locale to be used, otherwise, we will attempt to infer it (acceptable if |
| 215 * Dart is running on the client, we can infer from the browser). | 219 * Dart is running on the client, we can infer from the browser). |
| 216 */ | 220 */ |
| 217 DateFormat([formatDefinition = fullDate, locale]) { | 221 DateFormat([formatDefinition = fullDate, locale]) { |
| 218 this._formatDefinition = formatDefinition; | 222 this._formatDefinition = formatDefinition; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 247 | 251 |
| 248 /** | 252 /** |
| 249 * Formats a string indicating how long ago (negative [duration]) or how far | 253 * Formats a string indicating how long ago (negative [duration]) or how far |
| 250 * in the future (positive [duration]) some time is with respect to a | 254 * in the future (positive [duration]) some time is with respect to a |
| 251 * reference [date]. | 255 * reference [date]. |
| 252 */ | 256 */ |
| 253 String formatDurationFrom(Duration duration, Date date) { | 257 String formatDurationFrom(Duration duration, Date date) { |
| 254 return ''; | 258 return ''; |
| 255 } | 259 } |
| 256 } | 260 } |
| OLD | NEW |