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

Unified Diff: samples/ui_lib/util/DateUtils.dart

Issue 10411057: Deprecate use of timezones. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: samples/ui_lib/util/DateUtils.dart
diff --git a/samples/ui_lib/util/DateUtils.dart b/samples/ui_lib/util/DateUtils.dart
index 49abe2d478cc300d0185c78010cf3a11f49c1ae6..d18983810591548bd5303a092e3bf0623a900398 100644
--- a/samples/ui_lib/util/DateUtils.dart
+++ b/samples/ui_lib/util/DateUtils.dart
@@ -55,12 +55,12 @@ class DateUtils {
int zoneOffset = Math.parseInt(parts[5]) ~/ 100;
// Pretend it's a UTC time
- Date result = new Date.withTimeZone(
- year, month, day, hours, minutes, seconds, 0, new TimeZone.utc());
+ Date result = new Date(
+ year, month, day, hours, minutes, seconds, 0, isUtc: true);
// Shift it to the proper zone, but it's still a UTC time
result = result.subtract(new Duration(hours: zoneOffset));
// Then render it as a local time
- return result.changeTimeZone(new TimeZone.local());
+ return result.toLocal();
}
/** Parse a string like: 2011-07-19T22:03:04.000Z */
@@ -75,12 +75,9 @@ class DateUtils {
}
}
- TimeZone zone;
- if (text.endsWith('Z')) {
+ bool isUtc = text.endsWith('Z');
+ if (isUtc) {
text = text.substring(0, text.length - 1);
- zone = new TimeZone.utc();
- } else {
- zone = new TimeZone.local();
}
final parts = text.split('T');
@@ -99,7 +96,7 @@ class DateUtils {
milliseconds = Math.parseInt(seconds[1]);
}
- return new Date.withTimeZone(
+ return new Date(
Math.parseInt(date[0]),
Math.parseInt(date[1]),
Math.parseInt(date[2]),
@@ -107,7 +104,7 @@ class DateUtils {
Math.parseInt(time[1]),
Math.parseInt(seconds[0]),
milliseconds,
- zone);
+ isUtc: isUtc);
}
/**

Powered by Google App Engine
This is Rietveld 408576698