| Summary: | Access to Client Time Zone via RWT | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Tiber Sept <tibersept> |
| Component: | RWT | Assignee: | 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
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.
Having this method will be beneficial to our project as well. Casted one vote on this enhancement! :) With commit 56a51f58c74054f11ad39bef88296b22602f31f7 the timezone offset as returned by JavaScript can now be obtained via: RWT.getClient().getService( ClientInfo.class ).getTimezoneOffset() |