-
Type:
New Feature
-
Resolution: Done
-
Priority:
Normal
-
Affects Version/s: 8.6.2
-
Component/s: ZK Client Engine, ZK Update Engine
-
Security Level: Jimmy
-
None
-
None
Steps to Reproduce
run this code:
<zk xmlns:w="client"> <script> zk.afterLoad( function() { zAu.send(new zk.Event(zkdt(), 'onClientTimezone', zk.mm.tz.guess(), {toServer: true})); }); </script> <div onClientInfo="Clients.log(event.getTimeZone());" onClientTimezone="Clients.log(TimeZone.getTimeZone(event.data).toString());"> </div> </zk>
Current Result
ClientInfoEvent.getTimeZone() currently only returns a an offset timezone (GMT+-XX:XX), and not the real user's local timezone (e.g. Asia/Taipei, Europe/Berlin)
e.g. for taiwan it doesn't really matter since it has no DST rules
sun.util.calendar.ZoneInfo[id="GMT+08:00",offset=28800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] sun.util.calendar.ZoneInfo[id="Asia/Taipei",offset=28800000,dstSavings=0,useDaylight=false,transitions=42,lastRule=null]
for other counties the information makes a big difference:
sun.util.calendar.ZoneInfo[id="GMT+02:00",offset=7200000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
Expected Result
keep the current method for backwards compatibility (update the documentation that the timezone is a GMT based time zone without country information)
add a new function to also get the "real" localized user's timezone
Workaround
fire a custom event with the local timezone (already contained in the example above)
It uses moment.js' zk.mm.tz.guess() function documented here: https://momentjs.com/timezone/docs/#/using-timezones/guessing-user-timezone/