Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Calendar Month label is wrong when setDefaultDisplayTimezone set to earlier offset

    In the Calendar, the month will incorrectly show the label for the previous month if a call to DateUtil.setDefaultDisplayTimezone is made where the offset specifies an early TimeZone than the server is running in.

    So right now, given my server is in Eastern time (-04:00), if a call to setDefaultDisplayTimezone ("-03:00") is made and then the Calendar displayed, it will show "May" as the month even though the Calendar dates are in fact June.
    (see attached images).

    Using: SmartClient Version: v10.1p_2016-04-20/Pro Deployment (built 2016-04-20)

    Below is sample code to reproduce the problem. Just use the "Set TimeZone" menu button and pick an offset earlier than your server and look at the label on the Month. Also (as seen in cal_bad image), if you select a date on the Calendar you will see it is the proper value of June ... for the actual Date.

    Code:
    public class CalTest implements EntryPoint {
    
        private DateDisplayFormatter dayFormatter = new DateDisplayFormatter() {
            @Override
            public String format(Date date) {
                if (date == null) return null;
                DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd");
                return dateFormatter.format(date);
            }
        };
        private Layout layout = new VLayout(10);
        private Set<Date> dates = new TreeSet<>();
        private Label info = new Label();
        private Calendar calendar;
    
        @Override
        public void onModuleLoad() {
            info.setWidth100();
            info.setHeight(50);
            layout.setWidth100();
            layout.setHeight100();
            layout.setMargin(30);
            layout.addMember(info);
            createSetDefaultDisplayTimezone();
            createCalendar();
            layout.draw();
        }
    
        private void createCalendar() {
            if (calendar != null) calendar.destroy();
    
            calendar = new Calendar() {
                @Override
                public String getDayBodyHTML(Date date, CalendarEvent[] events, Calendar calendar, int rowNum, int colNum) {
                    String returnStr = dayFormatter.format(date) + "";
                    if (dates.contains(date)) {
                        returnStr += imgHTML("[SKIN]actions/approve.png", 16, 16, "image", null, null);
                    }
                    return returnStr;
                }
            };
    
            calendar.setWidth(400);
            calendar.setHeight(220);
            calendar.setShowDayView(false);
            calendar.setShowWeekView(false);
            calendar.setShowOtherDays(false);
            calendar.setShowDayHeaders(false);
            calendar.setShowDatePickerButton(true);
            calendar.setShowAddEventButton(false);
            calendar.setDisableWeekends(false);
            calendar.setShowDateChooser(true);
            calendar.setCanCreateEvents(false);
    
            calendar.addDayBodyClickHandler(new DayBodyClickHandler() {
                @Override
                public void onDayBodyClick(DayBodyClickEvent event) {
                    Date date = event.getDate();
                    if (dates.contains(date)) {
                        info.setContents("" + date + " removed.");
                        dates.remove(date);
                    } else {
                        info.setContents("" + date + " added.");
                        dates.add(date);
                    }
                    calendar.markForRedraw();
                }
            });
            layout.addMember(calendar);
        }
    
        private void setTimezoneAndRecreateCalendar(String value) {
            if (value == null) return;
            DateUtil.setDefaultDisplayTimezone(value);
            info.setContents("DateUtil.setDefaultDisplayTimezone(" + value + ")");
            layout.removeMember(calendar);
            createCalendar();
            layout.markForRedraw();
        }
    
        private void createSetDefaultDisplayTimezone() {
            Menu menu = new Menu();
            for (int i = 3; i <= 9; i++) {
                String tz = "-0" + i + ":00";
                final MenuItem item = new MenuItem(tz);
                item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
                    @Override
                    public void onClick(MenuItemClickEvent event) {
                        setTimezoneAndRecreateCalendar(item.getTitle());
                    }
                });
                menu.addItem(item);
    
            }
            MenuButton mb = new MenuButton("Set TimeZone", menu);
            layout.addMember(mb);
        }
    
    }
    Attached Files

    #2
    This has been fixed back to SGWT 5.1p/SC 10.1p - the change will be in the nightly builds dated 2016-06-07 and beyond.

    Comment


      #3
      I downloaded 06-07 and I get the following exception now trying to load the calendar if I call DateUtil.setDefaultDisplayTimezone

      Code:
      08:57:26.914:WARN:Log:TypeError: isc.DateUtil.$179o is not a function
      Stack from error.stack:
          Calendar.getDateLabelText(<no args: exited>) on [Calendar ID:isc_CalTest_2_0] @ ISC_Calendar.js:597:232
          Calendar.setDateLabel(<no args: exited>) on [Calendar ID:isc_CalTest_2_0] @ ISC_Calendar.js:597:9
          Calendar.createChildren(<no args: exited>) on [Calendar ID:isc_CalTest_2_0] @ ISC_Calendar.js:565:101
          Calendar.initWidget(<no args: exited>) on [Calendar ID:isc_CalTest_2_0] @ ISC_Calendar.js:449:373
          Canvas.init(<no args: exited>) on [Calendar ID:isc_CalTest_2_0] @ ISC_Core.js:2071:19
          Class.completeCreation(<no args: exited>) on [Calendar ID:isc_CalTest_2_0] @ ISC_Core.js:341:6
          [c]Class.create(<no args: exited>) on [Class Calendar] @ ISC_Core.js:228:1837
      Using: SmartClient Version: v10.1p_2016-06-07/Pro Deployment (built 2016-06-07)

      Comment


        #4
        We see this too. It will be resolved in the next nightlies. (The port of the change from SGWT 6.1d back to older branches wasn't as straightforward as assumed.)

        Comment


          #5
          I just noticed a similar problem exists now if you use a timezone behind the server (use to work OK). If you select a time zone in the sample test above that is earlier than server time and then click the arrows, the Calendar label is wrong. If you click the back arrow it shows August (when current month is October even though the month really is September after clicking the back arrow). If you click the forward arrow, the next month shows same label as current month, October in my case.

          Also, see the attached image where when it has the incorrect label and what you see when you click the "choose a date" icon.

          SmartClient Version: v10.1p_2016-08-25/Pro Deployment (built 2016-08-25)
          Attached Files

          Comment


            #6
            Any update on this?

            Comment


              #7
              We've applied a fix for this to SGWT 5.1p/SC 10.1p and newer branches. It should be in the nightly builds dated 2016-11-01 and beyond.

              Comment


                #8
                I am having a new issue with the latest fix. Run the sample above and do the following steps:
                1. ​Click "Set TimeZone" button and select first option "-03:00"
                2. Click the "Next" blue arrow to advance to next month: Calendar advances to Dec 1st 2016 (all good)
                3. Click the "Next" blue arrow to advance to next month again: Calendar remains on Dec 2016 but highlights the 30th (not good)
                4. Click the "Next" blue arrow to advance again: Nothing happens (you can try this step as many times as you like and nothing happens - Not good)
                5. Click the "Previous" blue arrow to go back a month: Calendar changes to October 30, 2016 (not good)
                6. Click the "Next" blue arrow to advance again: Nothing happens (you can try this step as many times as you like and nothing happens - Not good)
                7. Click the "Previous" blue arrow to go back a month: Calendar changes to August 30, 2016
                8. Click the "Next" blue arrow to advance to next month: Calendar advances to Sep 31 2016
                9. Click the "Next" blue arrow to advance to next month: Calendar advances to Oct 1 2016
                10. Click the "Next" blue arrow to advance to next month: Calendar advances to Oct 30 2016
                11. Click the "Next" blue arrow to advance again: Nothing happens (you can try this step as many times as you like and nothing happens)
                Using: SmartClient Version: v10.1p_2016-11-08/Pro Deployment (built 2016-11-08)

                Comment


                  #9
                  Which version and specific build of SmartGWT did you see this in? Please be very specific.

                  A bug where navigating with the next/previous buttons would cause event canvases not to be refreshed was fixed yesterday, in 11.0 (SGWT 6.0), and that is likely the bug you're seeing now.

                  Also, when you say "Calendar advances to Sep 31 2016", what do you actually mean by that? Where do you see that date, September 31? Is it in the toolstrip at the top? Is it the date of the first colukn in the grid? Are those two dates the same?
                  Last edited by Isomorphic; 8 Nov 2016, 12:25.

                  Comment


                    #10
                    The date in the Calendar that is highlighted, see attached image.

                    ​Also, I did state very specifically above what build I was using or do you need more than that?

                    Using: SmartClient Version: v10.1p_2016-11-08/Pro Deployment (built 2016-11-08)




                    Attached Files

                    Comment


                      #11
                      We've applied a fix for this issue to SGWT 5.1p/SC 10.1p and newer branches. It should be in the nightly builds dated 2016-11-11 and beyond.

                      Comment

                      Working...
                      X