Index: runtime/lib/date.dart |
diff --git a/runtime/lib/date.dart b/runtime/lib/date.dart |
index c02b5a708bc449dcb7e28827ede6dfc5bfe4ca9f..3c928c003dc457d00cb31b9786c27ac834d4d41b 100644 |
--- a/runtime/lib/date.dart |
+++ b/runtime/lib/date.dart |
@@ -130,6 +130,18 @@ class DateImplementation implements Date { |
return new Date.fromEpoch(value, targetTimeZone); |
} |
+ String get timeZoneName() { |
+ if (isUtc()) return "UTC"; |
+ return _timeZoneName(_equivalentSeconds(_secondsSinceEpoch)); |
+ } |
+ |
+ Duration get timeZoneOffset() { |
+ if (isUtc()) return new Duration(0); |
+ int offsetInSeconds = |
+ _timeZoneOffsetInSeconds(_equivalentSeconds(_secondsSinceEpoch)); |
+ return new Duration(seconds: offsetInSeconds); |
+ } |
+ |
int get year() { |
int secondsSinceEpoch = _secondsSinceEpoch; |
// According to V8 some library calls have troubles with negative values. |
@@ -401,6 +413,12 @@ class DateImplementation implements Date { |
static int _getCurrentMs() native "DateNatives_currentTimeMillis"; |
+ static String _timeZoneName(int secondsSinceEpoch) |
+ native "DateNatives_timeZoneName"; |
+ |
+ static int _timeZoneOffsetInSeconds(int secondsSinceEpoch) |
+ native "DateNatives_timeZoneOffsetInSeconds"; |
+ |
// TODO(floitsch): it would be more efficient if we didn't call the native |
// function for every member, but cached the broken-down date. |
static int _getYear(int secondsSinceEpoch, bool isUtc) |