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

Side by Side Diff: runtime/bin/http_utils.dart

Issue 10538105: Make isUtc a getter, change some method names in Date. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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 | « runtime/bin/file_impl.dart ('k') | runtime/bin/timer_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class _HttpUtils { 5 class _HttpUtils {
6 static String decodeUrlEncodedString(String urlEncoded) { 6 static String decodeUrlEncodedString(String urlEncoded) {
7 // First check the string for any encoding. 7 // First check the string for any encoding.
8 int index = 0; 8 int index = 0;
9 bool encoded = false; 9 bool encoded = false;
10 while (!encoded && index < urlEncoded.length) { 10 while (!encoded && index < urlEncoded.length) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // | "Sep" | "Oct" | "Nov" | "Dec" 93 // | "Sep" | "Oct" | "Nov" | "Dec"
94 94
95 // Format as RFC 1123 date. 95 // Format as RFC 1123 date.
96 static String formatDate(Date date) { 96 static String formatDate(Date date) {
97 List wkday = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; 97 List wkday = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
98 List month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 98 List month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
99 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; 99 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
100 100
101 Date d = date.toUtc(); 101 Date d = date.toUtc();
102 StringBuffer sb = new StringBuffer(); 102 StringBuffer sb = new StringBuffer();
103 sb.add(wkday[d.weekday]); 103 sb.add(wkday[d.weekday - 1]);
104 sb.add(", "); 104 sb.add(", ");
105 sb.add(d.day.toString()); 105 sb.add(d.day.toString());
106 sb.add(" "); 106 sb.add(" ");
107 sb.add(month[d.month - 1]); 107 sb.add(month[d.month - 1]);
108 sb.add(" "); 108 sb.add(" ");
109 sb.add(d.year.toString()); 109 sb.add(d.year.toString());
110 d.hours < 9 ? sb.add(" 0") : sb.add(" "); 110 d.hour < 9 ? sb.add(" 0") : sb.add(" ");
111 sb.add(d.hours.toString()); 111 sb.add(d.hour.toString());
112 d.minutes < 9 ? sb.add(":0") : sb.add(":"); 112 d.minute < 9 ? sb.add(":0") : sb.add(":");
113 sb.add(d.minutes.toString()); 113 sb.add(d.minute.toString());
114 d.seconds < 9 ? sb.add(":0") : sb.add(":"); 114 d.second < 9 ? sb.add(":0") : sb.add(":");
115 sb.add(d.seconds.toString()); 115 sb.add(d.second.toString());
116 sb.add(" GMT"); 116 sb.add(" GMT");
117 return sb.toString(); 117 return sb.toString();
118 } 118 }
119 119
120 static Date parseDate(String date, [bool strict = true]) { 120 static Date parseDate(String date, [bool strict = true]) {
121 final int SP = 32; 121 final int SP = 32;
122 List wkdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; 122 List wkdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
123 List weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", 123 List weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday",
124 "Friday", "Saturday", "Sunday"]; 124 "Friday", "Saturday", "Sunday"];
125 List months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 125 List months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 hours = expectNum(":"); 246 hours = expectNum(":");
247 minutes = expectNum(":"); 247 minutes = expectNum(":");
248 seconds = expectNum(" "); 248 seconds = expectNum(" ");
249 expect("GMT"); 249 expect("GMT");
250 } 250 }
251 expectEnd(); 251 expectEnd();
252 return new Date( 252 return new Date(
253 year, month + 1, day, hours, minutes, seconds, 0, isUtc: true); 253 year, month + 1, day, hours, minutes, seconds, 0, isUtc: true);
254 } 254 }
255 } 255 }
OLDNEW
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/timer_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698