diff options
author | Marc Englund <marc.englund@itmill.com> | 2011-03-29 07:31:44 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2011-03-29 07:31:44 +0000 |
commit | f39f819b4d90c8e988c5c04eed92e980095dc2b3 (patch) | |
tree | 51e643e82dab21356124e9c8efb5d72e8491d113 /src/com/vaadin/terminal/gwt/client/BrowserInfo.java | |
parent | f36607b3e64a0539490944df668eef3ae784d773 (diff) | |
download | vaadin-framework-f39f819b4d90c8e988c5c04eed92e980095dc2b3.tar.gz vaadin-framework-f39f819b4d90c8e988c5c04eed92e980095dc2b3.zip |
Implements #6691 get timezone offset from client.
svn changeset:18000/svn branch:6.6
Diffstat (limited to 'src/com/vaadin/terminal/gwt/client/BrowserInfo.java')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/BrowserInfo.java | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index 5981c2cfed..e4dd61b0b9 100644 --- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -65,10 +65,10 @@ public class BrowserInfo { private native boolean isIE8InIE7CompatibilityMode() /*-{ - var mode = $wnd.document.documentMode; - if (!mode) - return false; - return (mode == 7); + var mode = $wnd.document.documentMode; + if (!mode) + return false; + return (mode == 7); }-*/; /** @@ -282,17 +282,53 @@ public class BrowserInfo { public native static String getBrowserString() /*-{ - return $wnd.navigator.userAgent; + return $wnd.navigator.userAgent; }-*/; public native int getScreenWidth() - /*-{ - return $wnd.screen.width; + /*-{ + return $wnd.screen.width; }-*/; public native int getScreenHeight() - /*-{ - return $wnd.screen.height; + /*-{ + return $wnd.screen.height; + }-*/; + + /** + * Get's the timezone offset from GMT in minutes, as reported by the + * browser. DST affects this value. + * + * @return offset to GMT in minutes + */ + public native int getTimezoneOffset() + /*-{ + return new Date().getTimezoneOffset(); + }-*/; + + /** + * Get's the timezone offset from GMT in minutes, as reported by the browser + * AND adjusted to ignore daylight savings time. DST does not affect this + * value. + * + * @return offset to GMT in minutes + */ + public native int getRawTimezoneOffset() + /*-{ + var d = new Date(); + var tzo1 = d.getTimezoneOffset(); // current offset + + for (var m=12;m>0;m--) { + d.setUTCMonth(m); + var tzo2 = d.getTimezoneOffset(); + if (tzo1 != tzo2) { + // NOTE js indicates this 'backwards' (e.g -180) + return (tzo1 > tzo2 ? tzo1 : tzo2); // offset w/o DST + } + } + + return tzo1; // no DST + }-*/; } |