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

Unified Diff: sdk/lib/_internal/lib/js_helper.dart

Issue 78043002: Fix timezone extraction for IE and Opera. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove duplicated comment. Created 7 years, 1 month 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 | « no previous file | tests/corelib/corelib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/js_helper.dart
diff --git a/sdk/lib/_internal/lib/js_helper.dart b/sdk/lib/_internal/lib/js_helper.dart
index 507e89b59ca1481ef67033c3cb4221bc38bcd52a..7e753ef160c00c8277862e632ea5cf588e36f39b 100644
--- a/sdk/lib/_internal/lib/js_helper.dart
+++ b/sdk/lib/_internal/lib/js_helper.dart
@@ -518,29 +518,37 @@ class Primitives {
}
static String getTimeZoneName(receiver) {
- // When calling toString on a Date it will emit the timezone in parenthesis.
+ // Firefox and Chrome 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);
- String result = JS('String', r'/\((.*)\)/.exec(#.toString())[1]', d);
- if (result == null) {
- // Internet Explorer doesn't put the zone name into parenthesis:
- // For example: Thu Oct 31 14:07:44 PDT 2013
- result = JS('String',
- // Thu followed by a space.
- r'/^[A-Z,a-z]{3}\s'
- // Oct 31 followed by space.
- r'[A-Z,a-z]{3}\s\d+\s'
- // Time followed by a space.
- r'\d{2}:\d{2}:\d{2}\s'
- // The time zone name followed by a space.
- r'([A-Z]{3,5})\s'
- // The year.
- r'\d{4}$/'
- '.exec(#.toString())[1]',
- d);
- }
- return result;
+ List match = JS('JSArray|Null', r'/\((.*)\)/.exec(#.toString())', d);
+ if (match != null) return match[1];
+
+ // Internet Explorer 10+ emits the zone name without parenthesis:
+ // Example: Thu Oct 31 14:07:44 PDT 2013
+ match = JS('JSArray|Null',
+ // Thu followed by a space.
+ r'/^[A-Z,a-z]{3}\s'
+ // Oct 31 followed by space.
+ r'[A-Z,a-z]{3}\s\d+\s'
+ // Time followed by a space.
+ r'\d{2}:\d{2}:\d{2}\s'
+ // The time zone name followed by a space.
+ r'([A-Z]{3,5})\s'
+ // The year.
+ r'\d{4}$/'
+ '.exec(#.toString())',
+ d);
+ if (match != null) return match[1];
+
+ // IE 9 and Opera don't provide the zone name. We fall back to emitting the
+ // UTC/GMT offset.
+ // Example (IE9): Wed Nov 20 09:51:00 UTC+0100 2013
+ // (Opera): Wed Nov 20 2013 11:03:38 GMT+0100
+ match = JS('JSArray|Null', r'/(?:GMT|UTC)[+-]\d{4}/.exec(#.toString())', d);
+ if (match != null) return match[0];
+ return "";
}
static int getTimeZoneOffsetInMinutes(receiver) {
« no previous file with comments | « no previous file | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698