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

Unified Diff: runtime/lib/date.dart

Issue 10532068: Revert "Remove deprecated classes and functions in Date." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
« no previous file with comments | « lib/i18n/date_format.dart ('k') | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/date.dart
diff --git a/runtime/lib/date.dart b/runtime/lib/date.dart
index d39fb8cf92fc4108caf1d4f1583de18d838fc8c2..1654da7f6eaa355eb364c4e29de91bfff6a1c7c9 100644
--- a/runtime/lib/date.dart
+++ b/runtime/lib/date.dart
@@ -3,6 +3,18 @@
// BSD-style license that can be found in the LICENSE file.
// Dart core library.
+class TimeZoneImplementation implements TimeZone {
+ const TimeZoneImplementation.utc() : isUtc = true;
+ TimeZoneImplementation.local() : isUtc = false {}
+
+ bool operator ==(Object other) {
+ if (!(other is TimeZoneImplementation)) return false;
+ return isUtc == other.isUtc;
+ }
+
+ final bool isUtc;
+}
+
// VM implementation of DateImplementation.
class DateImplementation implements Date {
static final int _SECONDS_YEAR_2035 = 2051222400;
@@ -21,6 +33,17 @@ class DateImplementation implements Date {
if (value === null) throw new IllegalArgumentException();
}
+ DateImplementation.withTimeZone(int years,
+ int month,
+ int day,
+ int hours,
+ int minutes,
+ int seconds,
+ int milliseconds,
+ TimeZone timeZone)
+ : this(years, month, day, hours, minutes, seconds, milliseconds,
+ timeZone.isUtc);
+
DateImplementation.now()
: _isUtc = true,
value = _getCurrentMs() {
@@ -108,6 +131,13 @@ class DateImplementation implements Date {
return new DateImplementation.fromEpoch(value, true);
}
+ Date changeTimeZone(TimeZone targetTimeZone) {
+ if (targetTimeZone === null) {
+ targetTimeZone = new TimeZoneImplementation.local();
+ }
+ return new Date.fromEpoch(value, targetTimeZone.isUtc);
+ }
+
String get timeZoneName() {
if (isUtc()) return "UTC";
return _timeZoneName(_equivalentSeconds(_secondsSinceEpoch));
« no previous file with comments | « lib/i18n/date_format.dart ('k') | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698