Announcement

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

    Date Label on Calendar shows previous month

    Hi Isomorphic,

    We noticed an issue with the Calendar after upgrading to the latest build of SmartGWT 12.1p.

    The Calendar shows the correct days for current month, but the date label on the Calendar shows the previous month when using certain time zones (e.g. -03:00, Etc/UTC).

    Click image for larger version

Name:	calendar1.png
Views:	33
Size:	109.1 KB
ID:	266609

    Please run the following sample and set the time zone to "Etc/UTC" to reproduce the issue.

    Entry Point:
    Code:
    public class Sandbox4 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() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setAltKey(true);
            debugKey.setKeyName("D");
            Page.registerKey(debugKey, new PageKeyHandler() {
                @Override
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            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);
            }
    
            final MenuItem item = new MenuItem("ETC/UTC");
            item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
                @Override
                public void onClick(MenuItemClickEvent event) {
                    setTimezoneAndRecreateCalendar("-00:00");
                }
            });
            menu.addItem(item);
    
            MenuButton mb = new MenuButton("Set TimeZone", menu);
            layout.addMember(mb);
        }
    
    }
    Thanks

    #2
    We aren't seeing this problem running your code against latest SGWT 12.1 - what timezone are you in?

    Comment


      #3
      Eastern time zone for server and browser.

      Comment


        #4
        This was a problem caused by the DST crossover in October - we've addressed it for builds dated October 8 and later.

        Comment


          #5
          This is resolved in the October 8 build. Thanks!

          Comment

          Working...
          X