Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 329007

Summary: Access to Client Time Zone via RWT
Product: [RT] RAP Reporter: Tiber Sept <tibersept>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: gmalary, ronald.so, tbuschto
Version: unspecified   
Target Milestone: 2.0 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 390435    

Description Tiber Sept CLA 2010-10-29 04:04:44 EDT
Build Identifier: 20100617-1415

There is no method providing access to the client time zone. RWT provides access only to client locale via RWT.getLocale(). Thus, in some cases, internationalization is not easily realizable for dates.

Reproducible: Always

Steps to Reproduce:
1. Have client and web server in different time zones
2. Let user input date
3. Accept wrong date on server side
Comment 1 Tiber Sept CLA 2010-10-29 07:22:46 EDT
The following scenario:
  * UTC timezone on the server, i.e. ( Calendar and DateFormat UTC, 
    obviously  Date is always UTC ) 
  * Client enters the date in his local time 

DateTime widget delivers time entered by the user in user's local time zone. I need to know the user time zone to make the conversion to UTC. 

I got the following solution for now:
   * Two phase listeners
   * One phase listener to upload the following code:

var rightNow = new Date(); 
var jan = new Date( rightNow.getFullYear(), 0, 1, 2, 0, 0 );
var jul = new Date( rightNow.getFullYear(), 6, 1, 2, 0, 0);
var ofs = Math.max( jan.getTimezoneOffset(), jul.getTimezoneOffset() ) 
                    * 60000 * (-1);
var req = org.eclipse.swt.Request.getInstance();
req.addParameter( someConstant, ofs );
req.send();

   * Another phase listener waits for the result & converts it to
     java.uti.TimeZone - guessing the timezone from 
     TimeZone.getAvailableIDs( rawOffset )
   * Both remove themselves once they are run.
Comment 2 Ronald So CLA 2012-09-18 13:41:30 EDT
Having this method will be beneficial to our project as well.  Casted one vote on this enhancement! :)
Comment 3 Tim Buschtoens CLA 2012-12-07 11:56:01 EST
With commit 56a51f58c74054f11ad39bef88296b22602f31f7 the timezone offset as returned by JavaScript can now be obtained via:
RWT.getClient().getService( ClientInfo.class ).getTimezoneOffset()