Hello,
As discussed earlier on this list, I looked into creating timezone for parties. Here’s what I think is needed.
1. Java has built-in time zones for all major cities in the world (about 500 entries or so). They can be listed by String[] timeZones = java.util.TimeZone.getAvailableIDs(); I edited this list to produce timezones.ftl. I believe it should be stored as framework/common/webcommon/includes/timezones.ftl. 2. A corresponding screen widget is needed. I created one in framework/common/widget/CommonScreens.xml#timezones. This screen would be used very similar to cctypes screen. 3. Party entity needs additional field of type id-long to store timezone string. Id-long is needed since timezone string can be larger than 20 characters. Suggested name timeZoneId and description Preferred Time Zone. 4. There does not seem to be a requirement to run server at any specific timezone like UTC. 5. Java supports timezone independent time (in milliseconds) through Date class and the timezone dependent time through Calendar class. 6. When a user in timezone 1 sets an event, the Java code to store the event would look something like this: // Retrieve party’s timezone string in tz1Str TimeZone tz1 = TimeZone.getTimeZone(tz1Str); Calendar cal1 = Calendar.getInstance(tz1); // Now set event start time cal1.set(year, month, date, hour, min); Date eventTime = cal1.getTime(); eventTime is timezone independent and to be stored in database. 7. When a user in timezone 2 views an event, the Javacode looks something like this: // Retrieve event datetime in eventTime // Retrieve party’s timezone string in tz2Str TimeZone tz2 = TimeZone.getTimeZone(tz2Str); Calendar cal2 = Calendar.getInstance(tz2); cal2.setTime(eventTime); int hour = cal2.get(Calendar.HOUR);
8. Steps 6 and 7 are probably best served by couple of services that take the detail out of this.
I can implement this and pass patch files around if it sounds good.
Regards, Vinay Agarwal
_______________________________________________ Users mailing list [hidden email] http://lists.ofbiz.org/mailman/listinfo/users |
Some more comments: - With this implementation, if an application doesn’t use timezones consistently, then it would behave just like it does today. - If an application uses timezones for some parties and not for others, those without timezones would end up on the server time. - Since the list of timezones is long, it may be a good idea to duplicate most common a dozen or so timezones on top of the list.
-----Original Message-----
Hello,
As discussed earlier on this list, I looked into creating timezone for parties. Here’s what I think is needed.
1. Java has built-in time zones for all major cities in the world (about 500 entries or so). They can be listed by String[] timeZones = java.util.TimeZone.getAvailableIDs(); I edited this list to produce timezones.ftl. I believe it should be stored as framework/common/webcommon/includes/timezones.ftl. 2. A corresponding screen widget is needed. I created one in framework/common/widget/CommonScreens.xml#timezones. This screen would be used very similar to cctypes screen. 3. Party entity needs additional field of type id-long to store timezone string. Id-long is needed since timezone string can be larger than 20 characters. Suggested name timeZoneId and description Preferred Time Zone. 4. There does not seem to be a requirement to run server at any specific timezone like UTC. 5. Java supports timezone independent time (in milliseconds) through Date class and the timezone dependent time through Calendar class. 6. When a user in timezone 1 sets an event, the Java code to store the event would look something like this: // Retrieve party’s timezone string in tz1Str TimeZone tz1 = TimeZone.getTimeZone(tz1Str); Calendar cal1 = Calendar.getInstance(tz1); // Now set event start time cal1.set(year, month, date, hour, min); Date eventTime = cal1.getTime(); eventTime is timezone independent and to be stored in database. 7. When a user in timezone 2 views an event, the Javacode looks something like this: // Retrieve event datetime in eventTime // Retrieve party’s timezone string in tz2Str TimeZone tz2 = TimeZone.getTimeZone(tz2Str); Calendar cal2 = Calendar.getInstance(tz2); cal2.setTime(eventTime); int hour = cal2.get(Calendar.HOUR);
8. Steps 6 and 7 are probably best served by couple of services that take the detail out of this.
I can implement this and pass patch files around if it sounds good.
Regards, Vinay Agarwal
_______________________________________________ Users mailing list [hidden email] http://lists.ofbiz.org/mailman/listinfo/users |
Free forum by Nabble | Edit this page |