Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6689

ClientProperties.getTimeZone() has some issue when DST and UTC offsets are different

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 9.0.0-M2
    • 8.6.1, 7.15.0, 9.0.0-M3
    • wicket
    • None

    Description

      So ClientProperties.getTimeZone() got UTC offset 11 and DST offset 10 (Australia Sydney), and it picked the wrong one (UTC +11). The issue is the way it's calculating the UTC-DST difference and looking up in the available time zone IDs.

      					if (dstTimeZone != null &&
      						dstTimeZone.getRawOffset() != timeZone.getRawOffset())
      					{
      						int dstSaving = dstTimeZone.getRawOffset() - timeZone.getRawOffset();
      						String[] availableIDs = TimeZone.getAvailableIDs(timeZone.getRawOffset());
      						for (String availableID : availableIDs)
      						{
      							TimeZone zone = TimeZone.getTimeZone(availableID);
      							if (zone.getDSTSavings() == dstSaving)
      							{
      								// this is a best guess... still the start and end of the DST should
      								// be needed to know to be completely correct, or better yet
      								// not just the GMT offset but the TimeZone ID should be transfered
      								// from the browser.
      								timeZone = zone;
      								break;
      							}
      						}
      					}
      

      If dstTimeZone.getRawOffset() < timeZone.getRawOffset() then dstSaving is negative and it would never find any zone in the availableIDs.

      I'm sending a PR for this.

      Attachments

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              m4ns0ur Mansour Rahimi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: