Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: lib/i18n/date_format.dart

Issue 10494005: Updated message formatting to be more compatible with Dart string interpolation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More changes from review Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/i18n/intl.dart » ('j') | lib/i18n/intl.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 */ 101 */
102 102
103 #library('DateFormat'); 103 #library('DateFormat');
104 104
105 class DateFormat { 105 class DateFormat {
106 106
107 /** Definition of this object formats dates. */ 107 /** Definition of this object formats dates. */
108 var formatDefinition; 108 var formatDefinition;
109 109
110 /** Date/Time format patterns. */ 110 /** Date/Time format patterns. */
111 // TODO(alanknight): There's a style question of whether to use fullDate or 111 // TODO(alanknight): There's a style question of whether to use fullDate or
Emily Fortuna 2012/06/05 22:34:16 hooray for trailing whitespace removal!
112 // FULL_DATE naming conventions. 112 // FULL_DATE naming conventions.
113 static final int _fullDate = 0; 113 static final int _fullDate = 0;
114 static final int _longDate = 1; 114 static final int _longDate = 1;
115 static final int _mediumDate = 2; 115 static final int _mediumDate = 2;
116 static final int _shortDate = 3; 116 static final int _shortDate = 3;
117 static final int _fullTime = 4; 117 static final int _fullTime = 4;
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;}
Emily Fortuna 2012/06/05 17:40:09 change these to use the initializer list syntax: D
Alan Knight 2012/06/05 21:47:34 Done.
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 }
OLDNEW
« no previous file with comments | « no previous file | lib/i18n/intl.dart » ('j') | lib/i18n/intl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698