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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 expect(" "); | 235 expect(" "); |
236 day = expectNum(format == formatRfc1123 ? " " : "-"); | 236 day = expectNum(format == formatRfc1123 ? " " : "-"); |
237 month = expectMonth(format == formatRfc1123 ? " " : "-"); | 237 month = expectMonth(format == formatRfc1123 ? " " : "-"); |
238 year = expectNum(" "); | 238 year = expectNum(" "); |
239 hours = expectNum(":"); | 239 hours = expectNum(":"); |
240 minutes = expectNum(":"); | 240 minutes = expectNum(":"); |
241 seconds = expectNum(" "); | 241 seconds = expectNum(" "); |
242 expect("GMT"); | 242 expect("GMT"); |
243 } | 243 } |
244 expectEnd(); | 244 expectEnd(); |
245 return new Date( | 245 return new Date.utc(year, month + 1, day, hours, minutes, seconds, 0); |
246 year, month + 1, day, hours, minutes, seconds, 0, isUtc: true); | |
247 } | 246 } |
248 | 247 |
249 static Date parseCookieDate(String date) { | 248 static Date parseCookieDate(String date) { |
250 const List monthsLowerCase = const ["jan", "feb", "mar", "apr", "may", | 249 const List monthsLowerCase = const ["jan", "feb", "mar", "apr", "may", |
251 "jun", "jul", "aug", "sep", "oct", | 250 "jun", "jul", "aug", "sep", "oct", |
252 "nov", "dec"]; | 251 "nov", "dec"]; |
253 | 252 |
254 int position = 0; | 253 int position = 0; |
255 | 254 |
256 void error() { | 255 void error() { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 345 |
347 var timeList = timeStr.split(":"); | 346 var timeList = timeStr.split(":"); |
348 if (timeList.length !== 3) error(); | 347 if (timeList.length !== 3) error(); |
349 int hour = toInt(timeList[0]); | 348 int hour = toInt(timeList[0]); |
350 int minute = toInt(timeList[1]); | 349 int minute = toInt(timeList[1]); |
351 int second = toInt(timeList[2]); | 350 int second = toInt(timeList[2]); |
352 if (hour > 23) error(); | 351 if (hour > 23) error(); |
353 if (minute > 59) error(); | 352 if (minute > 59) error(); |
354 if (second > 59) error(); | 353 if (second > 59) error(); |
355 | 354 |
356 return new Date(year, month, dayOfMonth, hour, minute, second, 0, true); | 355 return new Date.utc(year, month, dayOfMonth, hour, minute, second, 0); |
357 } | 356 } |
358 } | 357 } |
OLD | NEW |