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

Side by Side Diff: samples/ui_lib/util/DateUtils.dart

Issue 11090016: Change core lib, dart2js, and more for new optional parameters syntax (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | « runtime/vm/snapshot_test.dart ('k') | tests/co19/co19-dart2dart.status » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * General purpose date/time utilities. 6 * General purpose date/time utilities.
7 */ 7 */
8 class DateUtils { 8 class DateUtils {
9 // TODO(jmesserly): localized strings 9 // TODO(jmesserly): localized strings
10 static const WEEKDAYS = const ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 10 static const WEEKDAYS = const ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 int hours = int.parse(timeParts[0]); 49 int hours = int.parse(timeParts[0]);
50 int minutes = int.parse(timeParts[1]); 50 int minutes = int.parse(timeParts[1]);
51 int seconds = int.parse(timeParts[2]); 51 int seconds = int.parse(timeParts[2]);
52 52
53 // TODO(jmesserly): TimeZone is not implemented in Dartium. This ugly 53 // TODO(jmesserly): TimeZone is not implemented in Dartium. This ugly
54 // hack applies the timezone from the string to the final time 54 // hack applies the timezone from the string to the final time
55 int zoneOffset = int.parse(parts[5]) ~/ 100; 55 int zoneOffset = int.parse(parts[5]) ~/ 100;
56 56
57 // Pretend it's a UTC time 57 // Pretend it's a UTC time
58 Date result = new Date( 58 Date result = new Date.utc(year, month, day, hours, minutes, seconds, 0);
59 year, month, day, hours, minutes, seconds, 0, isUtc: true);
60 // Shift it to the proper zone, but it's still a UTC time 59 // Shift it to the proper zone, but it's still a UTC time
61 result = result.subtract(new Duration(hours: zoneOffset)); 60 result = result.subtract(new Duration(hours: zoneOffset));
62 // Then render it as a local time 61 // Then render it as a local time
63 return result.toLocal(); 62 return result.toLocal();
64 } 63 }
65 64
66 /** Parse a string like: 2011-07-19T22:03:04.000Z */ 65 /** Parse a string like: 2011-07-19T22:03:04.000Z */
67 // TODO(jmesserly): workaround for Date.fromDate, which has issues: 66 // TODO(jmesserly): workaround for Date.fromDate, which has issues:
68 // * on Dart VM it doesn't handle all of ISO 8601. See b/5055106. 67 // * on Dart VM it doesn't handle all of ISO 8601. See b/5055106.
69 // * on DartC it doesn't work on Safari. See b/5062557. 68 // * on DartC it doesn't work on Safari. See b/5062557.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 176 }
178 String twoDigits(int n) { 177 String twoDigits(int n) {
179 if (n >= 10) return "${n}"; 178 if (n >= 10) return "${n}";
180 return "0${n}"; 179 return "0${n}";
181 } 180 }
182 String mm = 181 String mm =
183 twoDigits(duration.inMinutes.remainder(Duration.MINUTES_PER_HOUR)); 182 twoDigits(duration.inMinutes.remainder(Duration.MINUTES_PER_HOUR));
184 return "${hours}:${mm} ${a}"; 183 return "${hours}:${mm} ${a}";
185 } 184 }
186 } 185 }
OLDNEW
« no previous file with comments | « runtime/vm/snapshot_test.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698