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

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: Yet more review cleanups 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.
11 * 11 *
12 * This library uses the ICU/JDK date/time pattern specification as described 12 * This library uses the ICU/JDK date/time pattern specification as described
13 * below. 13 * below.
14 * 14 *
15 * Time Format Syntax: To specify the time format use a time pattern string. 15 * Time Format Syntax: To specify the time format use a time pattern string.
16 * In this pattern, following letters are reserved as pattern letters, which 16 * In this pattern, following letters are reserved as pattern letters, which
17 * are defined in the following manner: 17 * are defined in the following manner:
18 * 18 *
19 * Symbol Meaning Presentation Example 19 * Symbol Meaning Presentation Example
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 * the run, then the leftmost field is shortened by one character, and the 97 * the run, then the leftmost field is shortened by one character, and the
98 * entire run is parsed again. This is repeated until either the parse succeeds 98 * entire run is parsed again. This is repeated until either the parse succeeds
99 * or the leftmost field is one character in length. If the parse still fails at 99 * or the leftmost field is one character in length. If the parse still fails at
100 * that point, the parse of the run fails. 100 * that point, the parse of the run fails.
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 how this object formats dates.
Emily Fortuna 2012/06/05 22:34:17 the top line of this sort of comment should be bla
Alan Knight 2012/06/06 22:05:58 Done.
108 * (TODO) alanknight This might just be a String, but it's not clear yet.
109 */
108 var formatDefinition; 110 var formatDefinition;
109 111
112 /** The locale we use to format dates.
Emily Fortuna 2012/06/05 22:34:17 same.
Alan Knight 2012/06/06 22:05:58 Done.
113 * (TODO) alanknight Is there a Locale type? Or is this just a string?
114 */
115 var locale;
116
117
110 /** Date/Time format patterns. */ 118 /** Date/Time format patterns. */
111 // TODO(alanknight): There's a style question of whether to use fullDate or 119 // TODO(alanknight): There's a style question of whether to use fullDate or
112 // FULL_DATE naming conventions. 120 // FULL_DATE naming conventions.
113 static final int _fullDate = 0; 121 static final int _fullDate = 0;
114 static final int _longDate = 1; 122 static final int _longDate = 1;
115 static final int _mediumDate = 2; 123 static final int _mediumDate = 2;
116 static final int _shortDate = 3; 124 static final int _shortDate = 3;
117 static final int _fullTime = 4; 125 static final int _fullTime = 4;
118 static final int _longTime = 5; 126 static final int _longTime = 5;
119 static final int _mediumTime = 6; 127 static final int _mediumTime = 6;
120 static final int _shortTime = 7; 128 static final int _shortTime = 7;
121 static final int _fullDateTime = 8; 129 static final int _fullDateTime = 8;
122 static final int _longDateTime = 9; 130 static final int _longDateTime = 9;
123 static final int _mediumDateTime = 10; 131 static final int _mediumDateTime = 10;
124 static final int _shortDateTime = 11; 132 static final int _shortDateTime = 11;
125 133
126 /** 134 /**
127 * Named constructors for each of the above values. 135 * 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 */ 136 */
131 DateFormat.fullDate() : this.formatDefinition = _fullDate; 137 DateFormat.fullDate() : this.formatDefinition = _fullDate;
132 DateFormat.longDate() : this.formatDefinition = _longDate; 138 DateFormat.longDate() : this.formatDefinition = _longDate;
133 DateFormat.mediumDate() : this.formatDefinition = _mediumDate; 139 DateFormat.mediumDate() : this.formatDefinition = _mediumDate;
134 DateFormat.shortDate() : this.formatDefinition = _shortDate; 140 DateFormat.shortDate() : this.formatDefinition = _shortDate;
135 DateFormat.fullTime() : this.formatDefinition = _fullTime; 141 DateFormat.fullTime() : this.formatDefinition = _fullTime;
136 DateFormat.longTime() : this.formatDefinition = _longTime; 142 DateFormat.longTime() : this.formatDefinition = _longTime;
137 DateFormat.mediumTime() : this.formatDefinition = _mediumTime; 143 DateFormat.mediumTime() : this.formatDefinition = _mediumTime;
138 DateFormat.shortTime() : this.formatDefinition = _shortTime; 144 DateFormat.shortTime() : this.formatDefinition = _shortTime;
139 DateFormat.fullDateTime() : this.formatDefinition = _fullDateTime; 145 DateFormat.fullDateTime() : this.formatDefinition = _fullDateTime;
140 DateFormat.longDateTime() : this.formatDefinition = _longDateTime; 146 DateFormat.longDateTime() : this.formatDefinition = _longDateTime;
141 DateFormat.mediumDateTime() : this.formatDefinition = _mediumDateTime; 147 DateFormat.mediumDateTime() : this.formatDefinition = _mediumDateTime;
142 DateFormat.shortDateTime() : this.formatDefinition = _shortDateTime; 148 DateFormat.shortDateTime() : this.formatDefinition = _shortDateTime;
143 149
150 /**
151 * Explicit constructor given a particular format
152 */
144 DateFormat(this.formatDefinition); 153 DateFormat(this.formatDefinition);
145 154
146 /** 155 /**
147 * 156 * Constructors for dates/times that use a default format.
157 */
158 DateFormat.date([this.locale]) : formatDefinition = _fullDate;
159 DateFormat.time() : formatDefinition = _fullTime;
160 DateFormat.dateTime() : formatDefinition = _fullDateTime;
161
162 /**
163 *
148 */ 164 */
149 String parse(String inputString) { 165 String parse(String inputString) {
150 return inputString; 166 return inputString;
151 } 167 }
152 168
153 /** 169 /**
154 * Format the given [date] object according to preset pattern and current 170 * Format the given [date] object according to preset pattern and current
155 * locale and return a formated string for the given date. 171 * locale and return a formated string for the given date.
156 */ 172 */
157 String format(Date date, [TimeZone timeZone]) { 173 String format(Date date, [TimeZone timeZone]) {
158 // TODO(efortuna): optional TimeZone argument? TimeZone is deprecated... 174 // TODO(efortuna): optional TimeZone argument? TimeZone is deprecated...
159 return date.toString(); 175 return date.toString();
160 } 176 }
161 } 177 }
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