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).
Please run the following sample and set the time zone to "Etc/UTC" to reproduce the issue.
Entry Point:
Thanks
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).
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); } }
Comment