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

Unified Diff: lib/compiler/implementation/lib/js_helper.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 | « frog/lib/date_implementation.dart ('k') | lib/compiler/implementation/lib/mockimpl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/js_helper.dart
diff --git a/lib/compiler/implementation/lib/js_helper.dart b/lib/compiler/implementation/lib/js_helper.dart
index 9995935b32a80b604d564c98671d256450b2a224..c46f2f42b49b0d96f54c624576d92c45da2c46ba 100644
--- a/lib/compiler/implementation/lib/js_helper.dart
+++ b/lib/compiler/implementation/lib/js_helper.dart
@@ -328,6 +328,19 @@ class Primitives {
return JS('String', @'String.fromCharCode.apply(#, #)', null, charCodes);
}
+ static String getTimeZoneName(receiver) {
+ // When calling toString on a Date it will emit the timezone in parenthesis.
+ // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)".
+ // We extract this name using a regexp.
+ var d = lazyAsJsDate(receiver);
+ return JS('String', @'/\((.*)\)/.exec(#.toString())[1]', d);
+ }
+
+ static int getTimeZoneOffsetInMinutes(receiver) {
+ // Note that JS and Dart disagree on the sign of the offset.
+ return -JS('int', @'#.getTimezoneOffset()', lazyAsJsDate(receiver));
+ }
+
static valueFromDecomposedDate(years, month, day, hours, minutes, seconds,
milliseconds, isUtc) {
checkInt(years);
« no previous file with comments | « frog/lib/date_implementation.dart ('k') | lib/compiler/implementation/lib/mockimpl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698