Isomorphic,
When setting the today background color for a Calendar, it always uses the browser's native time zone to determine today's date; however, this can result in the wrong date for today being used when setting the default display time zone if today is the next/previous day in that time zone.
Please see the following standalone test case that illustrates this problem.
The Calendar_NoTZ screenshot shows the calendar without the display time zone set. It has the correct date for today (Aug 2) in the browser's time zone.
The Calendar_TZ screenshot shows that calendar after setting the display time zone to +10:00. It selects the correct current date (Aug 3), however, the date for today (Aug 2) is wrong.
Thanks
When setting the today background color for a Calendar, it always uses the browser's native time zone to determine today's date; however, this can result in the wrong date for today being used when setting the default display time zone if today is the next/previous day in that time zone.
Please see the following standalone test case that illustrates this problem.
Code:
public class CalTest extends VLayout implements EntryPoint { private static final String TODAY_BACKGROUND_COLOR = "#FF0000"; private Label info; private Calendar calendar; @Override public void onModuleLoad() { setWidth100(); setHeight100(); setMargin(30); info = new Label(); info.setWidth100(); info.setHeight(50); addMember(info); createSetDefaultDisplayTimezone(); createCalendar(); draw(); } private void createCalendar() { if (calendar != null) calendar.destroy(); calendar = new Calendar() { @Override protected String getDayBodyHTML(java.util.Date date, CalendarEvent[] events, Calendar calendar, int rowNum, int colNum) { return DateUtil.format(date, "d"); } }; calendar.setWidth(500); calendar.setHeight(220); calendar.setShowDayView(Boolean.FALSE); calendar.setShowWeekView(Boolean.FALSE); calendar.setShowAddEventButton(Boolean.FALSE); calendar.setShowDayHeaders(Boolean.FALSE); calendar.setCanCreateEvents(Boolean.FALSE); calendar.setShowDatePickerButton(Boolean.FALSE); calendar.setShowDateChooser(Boolean.FALSE); calendar.setShowOtherDays(Boolean.FALSE); calendar.setDisableWeekends(Boolean.FALSE); calendar.setTodayBackgroundColor(TODAY_BACKGROUND_COLOR); addMember(calendar); } private void setTimezoneAndRecreateCalendar(String value) { if (value == null) return; DateUtil.setDefaultDisplayTimezone(value); info.setContents("DateUtil.setDefaultDisplayTimezone(" + value + ")"); removeMember(calendar); createCalendar(); markForRedraw(); } private void createSetDefaultDisplayTimezone() { Menu menu = new Menu(); for (int i = 2; i <= 10; i += 2) { String offset = "+0" + i + ":00"; final MenuItem item = new MenuItem(offset); 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); addMember(mb); } }
The Calendar_TZ screenshot shows that calendar after setting the display time zone to +10:00. It selects the correct current date (Aug 3), however, the date for today (Aug 2) is wrong.
Thanks
Comment