| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Utility functions for working with dates with HTTP specific date | 8 * Utility functions for working with dates with HTTP specific date |
| 9 * formats. | 9 * formats. |
| 10 */ | 10 */ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 DateTime d = date.toUtc(); | 45 DateTime d = date.toUtc(); |
| 46 StringBuffer sb = new StringBuffer() | 46 StringBuffer sb = new StringBuffer() |
| 47 ..write(wkday[d.weekday - 1]) | 47 ..write(wkday[d.weekday - 1]) |
| 48 ..write(", ") | 48 ..write(", ") |
| 49 ..write(d.day.toString()) | 49 ..write(d.day.toString()) |
| 50 ..write(" ") | 50 ..write(" ") |
| 51 ..write(month[d.month - 1]) | 51 ..write(month[d.month - 1]) |
| 52 ..write(" ") | 52 ..write(" ") |
| 53 ..write(d.year.toString()) | 53 ..write(d.year.toString()) |
| 54 ..write(d.hour < 9 ? " 0" : " ") | 54 ..write(d.hour <= 9 ? " 0" : " ") |
| 55 ..write(d.hour.toString()) | 55 ..write(d.hour.toString()) |
| 56 ..write(d.minute < 9 ? ":0" : ":") | 56 ..write(d.minute <= 9 ? ":0" : ":") |
| 57 ..write(d.minute.toString()) | 57 ..write(d.minute.toString()) |
| 58 ..write(d.second < 9 ? ":0" : ":") | 58 ..write(d.second <= 9 ? ":0" : ":") |
| 59 ..write(d.second.toString()) | 59 ..write(d.second.toString()) |
| 60 ..write(" GMT"); | 60 ..write(" GMT"); |
| 61 return sb.toString(); | 61 return sb.toString(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Parse a date string in either of the formats | 65 * Parse a date string in either of the formats |
| 66 * [RFC-1123](http://tools.ietf.org/html/rfc1123 "RFC-1123"), | 66 * [RFC-1123](http://tools.ietf.org/html/rfc1123 "RFC-1123"), |
| 67 * [RFC-850](http://tools.ietf.org/html/rfc850 "RFC-850") or | 67 * [RFC-850](http://tools.ietf.org/html/rfc850 "RFC-850") or |
| 68 * ANSI C's asctime() format. These formats are listed here. | 68 * ANSI C's asctime() format. These formats are listed here. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 int hour = toInt(timeList[0]); | 305 int hour = toInt(timeList[0]); |
| 306 int minute = toInt(timeList[1]); | 306 int minute = toInt(timeList[1]); |
| 307 int second = toInt(timeList[2]); | 307 int second = toInt(timeList[2]); |
| 308 if (hour > 23) error(); | 308 if (hour > 23) error(); |
| 309 if (minute > 59) error(); | 309 if (minute > 59) error(); |
| 310 if (second > 59) error(); | 310 if (second > 59) error(); |
| 311 | 311 |
| 312 return new DateTime.utc(year, month, dayOfMonth, hour, minute, second, 0); | 312 return new DateTime.utc(year, month, dayOfMonth, hour, minute, second, 0); |
| 313 } | 313 } |
| 314 } | 314 } |
| OLD | NEW |