Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4334

provide the localized timezone ID in the onClientInfo event

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: 8.6.2
    • Fix Version/s: 9.0.0
    • Security Level: Jimmy
    • Labels:
      None

      Description

      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/

        Attachments

          Activity

            People

            • Assignee:
              rudyhuang rudyhuang
              Reporter:
              cor3000 cor3000
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h