| 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 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // month = "Jan" | "Feb" | "Mar" | "Apr" | 91 // month = "Jan" | "Feb" | "Mar" | "Apr" |
| 92 // | "May" | "Jun" | "Jul" | "Aug" | 92 // | "May" | "Jun" | "Jul" | "Aug" |
| 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.changeTimeZone(new TimeZone.utc()); | 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]); |
| 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.hours < 9 ? sb.add(" 0") : sb.add(" "); |
| 111 sb.add(d.hours.toString()); | 111 sb.add(d.hours.toString()); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 expect(" "); | 227 expect(" "); |
| 228 day = expectNum(format == formatRfc1123 ? " " : "-"); | 228 day = expectNum(format == formatRfc1123 ? " " : "-"); |
| 229 month = expectMonth(format == formatRfc1123 ? " " : "-"); | 229 month = expectMonth(format == formatRfc1123 ? " " : "-"); |
| 230 year = expectNum(" "); | 230 year = expectNum(" "); |
| 231 hours = expectNum(":"); | 231 hours = expectNum(":"); |
| 232 minutes = expectNum(":"); | 232 minutes = expectNum(":"); |
| 233 seconds = expectNum(" "); | 233 seconds = expectNum(" "); |
| 234 expect("GMT"); | 234 expect("GMT"); |
| 235 } | 235 } |
| 236 expectEnd(); | 236 expectEnd(); |
| 237 TimeZone utc = new TimeZone.utc(); | 237 return new Date( |
| 238 return new Date.withTimeZone( | 238 year, month + 1, day, hours, minutes, seconds, 0, isUtc: true); |
| 239 year, month + 1, day, hours, minutes, seconds, 0, utc); | |
| 240 } | 239 } |
| 241 } | 240 } |
| OLD | NEW |