| 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 28 matching lines...) Expand all Loading... |
| 39 */ | 39 */ |
| 40 static String format(DateTime date) { | 40 static String format(DateTime date) { |
| 41 const List wkday = const ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; | 41 const List wkday = const ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; |
| 42 const List month = const ["Jan", "Feb", "Mar", "Apr", "May", "Jun", | 42 const List month = const ["Jan", "Feb", "Mar", "Apr", "May", "Jun", |
| 43 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; | 43 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; |
| 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 <= 9 ? "0" : "") |
| 49 ..write(d.day.toString()) | 50 ..write(d.day.toString()) |
| 50 ..write(" ") | 51 ..write(" ") |
| 51 ..write(month[d.month - 1]) | 52 ..write(month[d.month - 1]) |
| 52 ..write(" ") | 53 ..write(" ") |
| 53 ..write(d.year.toString()) | 54 ..write(d.year.toString()) |
| 54 ..write(d.hour <= 9 ? " 0" : " ") | 55 ..write(d.hour <= 9 ? " 0" : " ") |
| 55 ..write(d.hour.toString()) | 56 ..write(d.hour.toString()) |
| 56 ..write(d.minute <= 9 ? ":0" : ":") | 57 ..write(d.minute <= 9 ? ":0" : ":") |
| 57 ..write(d.minute.toString()) | 58 ..write(d.minute.toString()) |
| 58 ..write(d.second <= 9 ? ":0" : ":") | 59 ..write(d.second <= 9 ? ":0" : ":") |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 int hour = toInt(timeList[0]); | 306 int hour = toInt(timeList[0]); |
| 306 int minute = toInt(timeList[1]); | 307 int minute = toInt(timeList[1]); |
| 307 int second = toInt(timeList[2]); | 308 int second = toInt(timeList[2]); |
| 308 if (hour > 23) error(); | 309 if (hour > 23) error(); |
| 309 if (minute > 59) error(); | 310 if (minute > 59) error(); |
| 310 if (second > 59) error(); | 311 if (second > 59) error(); |
| 311 | 312 |
| 312 return new DateTime.utc(year, month, dayOfMonth, hour, minute, second, 0); | 313 return new DateTime.utc(year, month, dayOfMonth, hour, minute, second, 0); |
| 313 } | 314 } |
| 314 } | 315 } |
| OLD | NEW |