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

Side by Side Diff: sdk/lib/io/http_date.dart

Issue 274243002: http_date: produce leading zero on day component (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | « no previous file | tests/standalone/io/http_date_test.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 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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/http_date_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698