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

Unified Diff: runtime/lib/date.dart

Issue 10417009: Reapply "Add support for timezone offset and timezone name." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing semicolon. 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
« no previous file with comments | « runtime/lib/date.cc ('k') | runtime/vm/bootstrap_natives.h » ('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 3e33c3aa2b266269f0aae52157da485fc6d9c756..97395aed124284628348d47c4de312c9fddf5805 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)
« no previous file with comments | « runtime/lib/date.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698